Fix backslash-escapes in url()s (#1429)

Closes #1399
This commit is contained in:
Natalie Weizenbaum 2021-08-11 00:02:23 +00:00 committed by GitHub
parent 54d16c0ac4
commit 5f4994e487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -2,6 +2,8 @@
* Allow `if` to be used as an unquoted string. * Allow `if` to be used as an unquoted string.
* Properly parse backslash escapes within `url()` expressions.
### Command Line Interface ### Command Line Interface
* Strip CRLF newlines from snippets of the original stylesheet that are included * Strip CRLF newlines from snippets of the original stylesheet that are included

View File

@ -395,14 +395,14 @@ class Parser {
var next = scanner.peekChar(); var next = scanner.peekChar();
if (next == null) { if (next == null) {
break; break;
} else if (next == $backslash) {
buffer.write(escape());
} else if (next == $percent || } else if (next == $percent ||
next == $ampersand || next == $ampersand ||
next == $hash || next == $hash ||
(next >= $asterisk && next <= $tilde) || (next >= $asterisk && next <= $tilde) ||
next >= 0x0080) { next >= 0x0080) {
buffer.writeCharCode(scanner.readChar()); buffer.writeCharCode(scanner.readChar());
} else if (next == $backslash) {
buffer.write(escape());
} else if (isWhitespace(next)) { } else if (isWhitespace(next)) {
whitespace(); whitespace();
if (scanner.peekChar() != $rparen) break; if (scanner.peekChar() != $rparen) break;

View File

@ -2911,14 +2911,14 @@ abstract class StylesheetParser extends Parser {
var next = scanner.peekChar(); var next = scanner.peekChar();
if (next == null) { if (next == null) {
break; break;
} else if (next == $backslash) {
buffer.write(escape());
} else if (next == $exclamation || } else if (next == $exclamation ||
next == $percent || next == $percent ||
next == $ampersand || next == $ampersand ||
(next >= $asterisk && next <= $tilde) || (next >= $asterisk && next <= $tilde) ||
next >= 0x0080) { next >= 0x0080) {
buffer.writeCharCode(scanner.readChar()); buffer.writeCharCode(scanner.readChar());
} else if (next == $backslash) {
buffer.write(escape());
} else if (next == $hash) { } else if (next == $hash) {
if (scanner.peekChar(1) == $lbrace) { if (scanner.peekChar(1) == $lbrace) {
buffer.add(singleInterpolation()); buffer.add(singleInterpolation());