Skip to content

Commit

Permalink
fix: Restrict YAML 1.1 boolean strings to their explicit capitalizati…
Browse files Browse the repository at this point in the history
…on (#530)
  • Loading branch information
klao committed Mar 7, 2024
1 parent 4aa56d3 commit 1c6fd6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/schema/yaml-1.1/bool.ts
Expand Up @@ -21,7 +21,7 @@ export const falseTag: ScalarTag & { test: RegExp } = {
identify: value => value === false,
default: true,
tag: 'tag:yaml.org,2002:bool',
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,
test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
resolve: () => new Scalar(false),
stringify: boolStringify
}
6 changes: 5 additions & 1 deletion tests/doc/stringify.ts
Expand Up @@ -633,7 +633,7 @@ describe('scalar styles', () => {

test('bool Scalar styles on YAML1.1', () => {
const doc = YAML.parseDocument(
'[ n, N, NO, no, No, False, false, FALSE, Off, off, OFF, y, Y, Yes, yes, YES, true, True, TRUE, ON, on, On ]',
'[ n, N, NO, no, No, False, false, FALSE, FALse, Off, off, OFF, OfF, y, Y, Yes, yes, YES, true, True, TRUE, ON, on, On ]',
{ schema: 'yaml-1.1' }
)
const str = `[
Expand All @@ -645,9 +645,11 @@ describe('scalar styles', () => {
False,
false,
FALSE,
FALse,
Off,
off,
OFF,
OfF,
y,
Y,
Yes,
Expand All @@ -670,9 +672,11 @@ describe('scalar styles', () => {
false,
false,
false,
'FALse',
false,
false,
false,
'OfF',
true,
true,
true,
Expand Down

0 comments on commit 1c6fd6a

Please sign in to comment.