-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[SHIRO-530] INI parser does not properly handled backslashes at end o… #210
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
Conversation
…f values - Do not skip escape characters for the value (new behaviour demanded by SHIRO-530). - rearrange and comment tests to reflect old and new, desired behaviour. Signed-off-by: Benjamin Marwell <bmarwell@gmail.com>
|
@bmhm sounds good! |
fpapon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
@bdemers can you review please just before I merge it? |
|
retest this please |
|
|
||
| test = "Truth=Beau\\ty"; | ||
| // SHIRO-530: Keep backslashes in value. | ||
| test = "Truth=Beauty\\"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this one wrap? and the next line would be included?
i.e. something like:
Truth=Beauty\
more text hereWhich would be something like Truth=Beatuty\\\nmore text here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it should not, because we are calling the splitKeyValue method. The backslashes at the end are resolved in the caller method. When arriving at this point, the wrapping would have already occured. Took me a while, too, to figure this one out. But I did not bother to add more comments. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdemers see here:
shiro/config/core/src/main/java/org/apache/shiro/config/Ini.java
Lines 609 to 631 in b50b829
| private static Map<String, String> toMapProps(String content) { | |
| Map<String, String> props = new LinkedHashMap<String, String>(); | |
| String line; | |
| StringBuilder lineBuffer = new StringBuilder(); | |
| Scanner scanner = new Scanner(content); | |
| while (scanner.hasNextLine()) { | |
| line = StringUtils.clean(scanner.nextLine()); | |
| if (isContinued(line)) { | |
| //strip off the last continuation backslash: | |
| line = line.substring(0, line.length() - 1); | |
| lineBuffer.append(line); | |
| continue; | |
| } else { | |
| lineBuffer.append(line); | |
| } | |
| line = lineBuffer.toString(); | |
| lineBuffer = new StringBuilder(); | |
| String[] kvPair = splitKeyValue(line); | |
| props.put(kvPair[0], kvPair[1]); | |
| } | |
| return props; | |
| } |
Please check if I did not mis-read it.
bdemers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question in there (the backslashes are making my brain hurt)
|
I think the complexity is that we can have some regex or URI in the value, so we have to deal correctly with the backslash |
bdemers
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bmhm Thanks for the link, that resolves the open question I had
Great work!
|
@bmhm Thanks for the great work ;) |
…f values
Signed-off-by: Benjamin Marwell bmarwell@gmail.com
Alternative to #209