Skip to content

Commit

Permalink
fix: Carriage return in tag shorthand (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Nov 3, 2023
1 parent e8576e8 commit 4af7419
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/doc/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class Directives {
return verbatim
}

const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/) as string[]
const [, handle, suffix] = source.match(/^(.*!)([^!]*)$/s) as string[]
if (!suffix) onError(`The ${source} tag has no suffix`)
const prefix = this.tags[handle]
if (prefix) {
Expand Down
6 changes: 6 additions & 0 deletions tests/doc/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ describe('tags', () => {
expect(doc.errors).toHaveLength(1)
expect(doc.errors[0].message).toMatch('URIError')
})

test('CR in tag shorthand (eemeli/yaml#501', () => {
const doc = parseDocument(': | !\r!')
const err = doc.errors.find(err => err.code === 'TAG_RESOLVE_FAILED')
expect(err).not.toBeFalsy()
})
})

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

0 comments on commit 4af7419

Please sign in to comment.