laforge
laforge copied to clipboard
RenderHCLv2Object doesn't handle '\' characters
RenderHCLv2Object doesn't handle \
characters.
In the case of trying to run configure
, it will fail to render user.laforge.tmpl
and as such the program will be unable to write the results of rendering the template.
This is particularly annoying as, in my case, os.User.Username
- the value that this program sets to core.User::ID
and is part of the rendered template - includes a \
.
Actual Behavior
This is on Windows 10; same results with either cmd or powershell.
%GOPATH%\bin>laforge.exe configure
[LAFORGE:cli] INFO No config found!
? Enter your name: rrd
? Enter your email address: [email protected]
? Write configuration to ~/.laforge/global.laforge? Yes
[LAFORGE:cli] FATAL Terminated due to error: At 3:23: illegal char escape
%GOPATH%\bin>laforge.exe configure
[LAFORGE:cli] INFO No config found!
? Enter your name: abc\xyz
? Enter your email address: [email protected]
? Write configuration to ~/.laforge/global.laforge? Yes
[LAFORGE:cli] FATAL Terminated due to error: At 4:16: illegal char escape
%GOPATH%\bin>laforge.exe configure
[LAFORGE:cli] INFO No config found!
? Enter your name: abc\nnn
? Enter your email address: [email protected]
? Write configuration to ~/.laforge/global.laforge? Yes
[LAFORGE:cli] FATAL Terminated due to error: At 3:23: illegal char escape
%GOPATH%\bin>laforge.exe configure
[LAFORGE:cli] INFO No config found!
? Enter your name: a\u
? Enter your email address: x
? Write configuration to ~/.laforge/global.laforge? Yes
[LAFORGE:cli] FATAL Terminated due to error: At 4:15: literal not terminated
Expected Behavior
%GOPATH%\bin>TYPE %USERPROFILE%\.laforge\global.laforge
The system cannot find the file specified.
%GOPATH%\bin>laforge.exe configure
[LAFORGE:cli] INFO No config found!
? Enter your name: a\u
? Enter your email address: x
? Write configuration to ~/.laforge/global.laforge? Yes
[LAFORGE:cli] INFO Global configuration written to ~/.laforge/global.laforge
%GOPATH%\bin>TYPE %USERPROFILE%\.laforge\global.laforge
// DEFAULT LAFORGE GLOBAL CONFIGURATION
user "Desktop-123456\Raymond" {
name = "a\u"
uuid = "12345678-90AB-CDEF-…"
email = "x"
}
Substitute the \
s for \\
s if that's necessary for reading the configuration later, but the primary point is that I expect the program to write a configuration with \
s represented in the written values.
Just pushed an update to this. I don't have a tokenized generator of the config language, so it's being done in templates.
I've added a new template escaping function specifically for special characters like that. Just need to go through all the templates and add it in.