Skip to content

Commit 4af7419

Browse files
committed
fix: Carriage return in tag shorthand (#501)
1 parent e8576e8 commit 4af7419

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/doc/directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class Directives {
143143
return verbatim
144144
}
145145

146-
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/) as string[]
146+
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s) as string[]
147147
if (!suffix) onError(`The ${source} tag has no suffix`)
148148
const prefix = this.tags[handle]
149149
if (prefix) {

tests/doc/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ describe('tags', () => {
112112
expect(doc.errors).toHaveLength(1)
113113
expect(doc.errors[0].message).toMatch('URIError')
114114
})
115+
116+
test('CR in tag shorthand (eemeli/yaml#501', () => {
117+
const doc = parseDocument(': | !\r!')
118+
const err = doc.errors.find(err => err.code === 'TAG_RESOLVE_FAILED')
119+
expect(err).not.toBeFalsy()
120+
})
115121
})
116122

117123
test('eemeli/yaml#97', () => {

0 commit comments

Comments
 (0)