fix: Carriage return in tag shorthand (#501) · eemeli/yaml@4af7419

2 files changed

lines changed

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) {

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', () => {