-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Selector quoted attribute values #6
Selector quoted attribute values #6
Conversation
Thanks, I agree that this should be fixed. Will take a look at the patches in detail in a bit. |
| Some c -> Buffer.add_char buffer c; Stream.junk stream; loop () | ||
in | ||
loop () | ||
match Stream.peek stream with |
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.
nit: git diff
shows a dangling space at the end of this line.
Looks great! Thanks again. Could you please amend the first commit to take care of the inline nit? Would you prefer a speedy update in OPAM, or are you comfortable using a development version for a while? |
Also, this intentionally does not try to correctly support newlines, as described in https://www.w3.org/TR/CSS21/syndata.html#strings, but that's fine. That can be added later if someone needs it. I just want to note it, in case someone looks in this discussion. |
Thanks, lambda-soup is a cool library, appreciate your work on it too. I added a commit to take care of the dangling space. I don't need a speedy opam update, development version is fine. It indeed does not try to support newlines (neither the precise syntax specified in the W3C reference, which is more restrictive), because in pure OCaml using a plain newline would do just fine I think. I guess problems could appear if one try to read W3C-compliant selectors from an external source, but as you state, it can be quite easily added later if needed : the lesser, the safer ^^ |
Could you please squash the whitespace fix into 55c3b91, giving this PR a 2-commit history? It will then be as nice and tidy as when originally submitted (thank you for that!), and ready for merge. |
28d61a6
to
fadd7fc
Compare
Should be ok now |
Much appreciated! |
According to reference https://www.w3.org/TR/css3-selectors/#attribute-selectors and https://www.w3.org/TR/CSS21/syndata.html#strings, attributes values in selectors can be either identifier or quoted strings.
While identifiers are syntactically heavily restricted and I don't see any problem with lambdasoup being more resilient, selectors like
soup $ "[attr='a value']"
match markups of the form
<markup attr="'a value'"/>
and similarly
soup $ "[attr=\"a value\"]"
match markups of the form
<markup attr=""a value""/>
I see a few problems with that :
<markup attr="a value">
.This PR tries to solve the problem by