Skip to content

Commit 58cc860

Browse files
committed
Fix carrier return parsing
1 parent 4fff8e4 commit 58cc860

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/tokenize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const AT = '@'.charCodeAt(0)
2222

2323
const RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g
2424
const RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g
25-
const RE_BAD_BRACKET = /.[\n"'(/\\]/
25+
const RE_BAD_BRACKET = /.[\r\n"'(/\\]/
2626
const RE_HEX_ESCAPE = /[\da-f]/i
2727

2828
module.exports = function tokenizer(input, options = {}) {

test/parse.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ test('should has false at hasBOM property', () => {
3434
is(css.first?.source?.input.hasBOM, false)
3535
})
3636

37+
test('parses carrier return', () => {
38+
throws(() => {
39+
parse('@font-face{ font:(\r/*);} body { a: "a*/)} a{}"}')
40+
}, /:1:46: Unclosed string/)
41+
})
42+
3743
test('saves source file', () => {
3844
let css = parse('a {}', { from: 'a.css' })
3945
is(css.first?.source?.input.css, 'a {}')

0 commit comments

Comments
 (0)