-
Notifications
You must be signed in to change notification settings - Fork 220
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
Fixes #23031 - parse server duid's with nested double quotes #571
Conversation
@@ -209,10 +209,11 @@ def server_duid | |||
Rsec::Fail.reset | |||
keyword = word('server-duid').fail 'keyword_server_duid' | |||
anything = /[^;,{}\s]+/.r | |||
literal = /"([^"]|\")*"/.r |
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.
It looks like ISC configuration parser treats all strings like that, isn't cleaner to use this in LITERAL
constant?
If it won't break our tests, I think we should go with:
Single quotes do not appear to be supported by the parser, if I am looking into the correct place in the codebase. https://lists.isc.org/pipermail/dhcp-users/2011-February/013135.html |
I think the ultimate goal should be parsing strings the same way as dhcpd's parser does. Unfortunately, I don't think it is doable using a non-monstrous regex (if at all). The reason I didn't reuse the regex the way you are suggesting is that it will also match comma-separated strings as one string, which breaks the parser. DUID is an outlier, as majority of the strings are host or option names and values, I think we are pretty safe with the fix in the PR. I'll add extending rsec parser with a custom string parser as a feature to smart-proxy's backlog. |
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.
Ok that's good. Thanks.
I think a similar change will be needed for the uid within a lease. |
I also think doing this for all strings won't hurt, the ISC parser does seem to work that way. |
I believe that literal should be |
@alvinstarr that regexp doesn't work for. Here is the uid that was tripping me up:
http://rubular.com/r/gqxRXXs1YZ The regexp in https://stackoverflow.com/questions/249791/regex-for-quoted-string-with-escaping-quotes seems to work but may have other problems. |
Please see my comment above. Feel free to experiment, but please run tests before proposing a fix. Please also note complicated regular expressions will be rejected. |
This may be better |
I am locking this conversation. If you are seeing this issue, please update the redmine ticket referenced in this PR, or create a new one. |
I am not sure if locking was necessary here, "this might be better" is appropriate comment although I do agree some of them can be useless when not properly tried and tested. However, I think leaving those comments "as-is" is probably preferred than locking discussion. |
No description provided.