Fix crsh with Unicode in environment vars

This commit is contained in:
Dave Thomas 2013-06-23 20:30:38 -05:00
parent dd277fd01a
commit 091405bce7

View file

@ -191,12 +191,12 @@ expand_env_variable(InStr, VarName, RawVarValue) ->
%% No variables to expand %% No variables to expand
InStr; InStr;
_ -> _ ->
ReOpts = [global, unicode], ReOpts = [global, unicode, {return, list}],
VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts), VarValue = re:replace(RawVarValue, "\\\\", "\\\\\\\\", ReOpts),
%% Use a regex to match/replace: %% Use a regex to match/replace:
%% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO} %% Given variable "FOO": match $FOO\s | $FOOeol | ${FOO}
RegEx = io_lib:format("\\\$(~s(\\s|$)|{~s})", [VarName, VarName]), 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. end.
vcs_vsn(Config, Vcs, Dir) -> vcs_vsn(Config, Vcs, Dir) ->