From 934ec7fdeff99fe95220f8a187968d0f584585ab Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Fri, 21 Jun 2013 23:40:32 -0500 Subject: [PATCH 1/3] =?UTF-8?q?Add=20one=20more=20"unicode"=20option=20in?= =?UTF-8?q?=20expand=5Fenv=5Fvariable=E2=80=94I=20have=20a=20bullet=20in?= =?UTF-8?q?=20my=20prompt=20that=20was=20blowing=20it=20up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/rebar_utils.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index fd93f98..9c7c064 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -191,7 +191,7 @@ expand_env_variable(InStr, VarName, RawVarValue) -> %% No variables to expand InStr; _ -> - VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global]), + VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global, unicode]), %% Use a regex to match/replace: %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]), From dd277fd01ac6da0661df878a123db93cd09f040e Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Sat, 22 Jun 2013 21:41:04 -0500 Subject: [PATCH 2/3] Fix crash when env vars contain utf8 chars --- src/rebar_utils.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 9c7c064..2731761 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -191,12 +191,12 @@ expand_env_variable(InStr, VarName, RawVarValue) -> %% No variables to expand InStr; _ -> - VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", [global, unicode]), + ReOpts = [global, unicode], + VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts), %% Use a regex to match/replace: %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]), - ReOpts = [global, {return, list}, unicode], - re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts) + re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts ++ [{return, list}]) end. vcs_vsn(Config, Vcs, Dir) -> From 091405bce7a59769a86fcbf8e44602c05b7082a1 Mon Sep 17 00:00:00 2001 From: Dave Thomas Date: Sun, 23 Jun 2013 20:30:38 -0500 Subject: [PATCH 3/3] Fix crsh with Unicode in environment vars --- src/rebar_utils.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 2731761..64ac4a9 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -191,12 +191,12 @@ expand_env_variable(InStr, VarName, RawVarValue) -> %% No variables to expand InStr; _ -> - ReOpts = [global, unicode], + ReOpts = [global, unicode, {return, list}], VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts), %% Use a regex to match/replace: %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]), - re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts ++ [{return, list}]) + re:replace(InStr, RegEx, [VarValue, "\\2"], ReOpts) end. vcs_vsn(Config, Vcs, Dir) ->