Skip to content

Commit 212f024

Browse files
committed
Fix: escape unit separator and del
1 parent 556861f commit 212f024

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

build/index.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function parse(source) {
8888
if (ch === `
8989
`)
9090
throw new SyntaxError(errorSnippet());
91-
if (ch < "")
91+
if (ch < " " || ch === "\x7F")
9292
throw new SyntaxError(errorSnippet());
9393
str += ch;
9494
}

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/maml.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function parse(source: string): any {
104104
break
105105
} else if ((ch as string) === '\n') {
106106
throw new SyntaxError(errorSnippet())
107-
} else if ((ch as string) < '\x1F') {
107+
} else if ((ch as string) < '\x20' || ch === '\x7F') {
108108
throw new SyntaxError(errorSnippet())
109109
} else {
110110
str += ch

test/error.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,12 @@ describe('error', () => {
5555
test('unescaped \u0000 inside string', () => {
5656
expect(() => parse('"\u0000"')).toThrow('Unexpected character "\\u0000" on line 1.')
5757
})
58+
59+
test('unescaped U+001F inside string', () => {
60+
expect(() => parse('"\u001F"')).toThrow('on line 1.')
61+
})
62+
63+
test('unescaped U+007F (DEL) inside string', () => {
64+
expect(() => parse('"\u007F"')).toThrow('on line 1.')
65+
})
5866
})

0 commit comments

Comments
 (0)