Skip to content

Commit 02299b9

Browse files
committed
Fix: allow literal tab
1 parent 212f024 commit 02299b9

5 files changed

Lines changed: 17 additions & 4 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 < " " || ch === "\x7F")
91+
if (ch < " " && 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: 1 addition & 1 deletion
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) < '\x20' || ch === '\x7F') {
107+
} else if (((ch as string) < '\x20' && ch !== '\t') || ch === '\x7F') {
108108
throw new SyntaxError(errorSnippet())
109109
} else {
110110
str += ch

test/parse.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ describe('extra', () => {
6161
expect('MAML' in globalThis).toBeTruthy()
6262
})
6363

64+
test('string allows literal tab', () => {
65+
const output = parse('"hello\tworld"')
66+
expect(output).toStrictEqual('hello\tworld')
67+
})
68+
69+
test('string rejects control char U+001F', () => {
70+
expect(() => parse('"\x1F"')).toThrow()
71+
})
72+
73+
test('string rejects DEL U+007F', () => {
74+
expect(() => parse('"\x7F"')).toThrow()
75+
})
76+
6477
test('raw string with CRLF newlines', () => {
6578
const output = parse('"""line1\r\nline2\r\nline3"""')
6679
expect(output).toStrictEqual('line1\r\nline2\r\nline3')

0 commit comments

Comments
 (0)