Skip to content

Commit

Permalink
Fix carrier return parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 28, 2023
1 parent 4fff8e4 commit 58cc860
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const AT = '@'.charCodeAt(0)

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

module.exports = function tokenizer(input, options = {}) {
Expand Down
6 changes: 6 additions & 0 deletions test/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ test('should has false at hasBOM property', () => {
is(css.first?.source?.input.hasBOM, false)
})

test('parses carrier return', () => {
throws(() => {
parse('@font-face{ font:(\r/*);} body { a: "a*/)} a{}"}')
}, /:1:46: Unclosed string/)
})

test('saves source file', () => {
let css = parse('a {}', { from: 'a.css' })
is(css.first?.source?.input.css, 'a {}')
Expand Down

0 comments on commit 58cc860

Please sign in to comment.