Fix: Unquoted url()
data URL values that contain +
#2633
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What: Closes #2597
Why: A value of
url(data:image/svg+xml)
without'
or"
produces a parse errorillegal unary "%", missing left-hand operand
- however, unquoted style is acceptable CSS3 syntax, so it should work in Stylus as well.How: Unlike the error message would suggest, the culprit is not the
%
in the URL, but instead it's the+
insvg+xml
- this makes Stylus think it's an expression, like in thebifs.url
test:stylus/test/cases/bifs.url.styl
Lines 10 to 13 in 9cb7635
I modified the the
urlchars
method in the lexer to accept+
as urlchars, but only when the currentstr
begins with a+
and letters (otherwise the BIF test above would fail). At this point of parsing, thestr
would look like+xml,...
so it's a fair guess that we have been parsing a data URL mimetype.However, this methodology isn't completely foolproof (i.e. it doesn't actually check that we're parsing a
data:
URL specifically), and although all the tests do currently pass, there is a chance this may cause other unintended edge case regressions.Checklist: