-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserving the backslash character #37
base: main
Are you sure you want to change the base?
Conversation
Hmm, I get it but this would be a breaking change since this behavior has been in the library since 2014. If you need this then this should be configurable. |
Thank you for your comment. |
I would expect a flag in the Global variable is not ok, unfortunately. This needs to be properly integrated and there need to be tests for this. |
Thank you for your suggestion. |
In order to propagate the flag Properties.KeepBackslash to the lexer, I had to make changes in the other structure and the argument of lex(). |
I gets back the two test cases I commented out in load_test.go. |
I think that my changes are ready to go. |
I've thought about this a bit more. The Java properties implementation silently drops single backslash characters to avoid tripping over invalid escape sequences. The Go version emulates that behavior.
(https://docs.oracle.com/javase/7/docs/api/java/util/Properties.html#load(java.io.Reader)) However, if you escape the backslash it works as expected. What am I missing? func TestBackslash(t *testing.T) {
input := "k\\\\ey=va\\\\lue"
p := mustParse(t, input)
assert.Equal(t, p.MustGet("k\\ey"), "va\\lue")
} |
Thank you for explaining the behavior. |
Hi, |
This change leaves the escape character backslash '' when the backslash isn't precede one of " :=fnrt" that need escaping. Currently, any backslash that isn't precede one of the escaped characters is simply dropped.
We don't know how each property value will be processed by the callers.
So, it would be better that the package 'properties' doesn't make modifications as possible because the backslash may be put on purpose.