From 1c6fd6a76a92ce8dda28a66b2af6f3e6a3182958 Mon Sep 17 00:00:00 2001 From: Mihaly Barasz Date: Thu, 7 Mar 2024 20:56:52 +0100 Subject: [PATCH] fix: Restrict YAML 1.1 boolean strings to their explicit capitalization (#530) --- src/schema/yaml-1.1/bool.ts | 2 +- tests/doc/stringify.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/schema/yaml-1.1/bool.ts b/src/schema/yaml-1.1/bool.ts index a6a4f696..10d68d40 100644 --- a/src/schema/yaml-1.1/bool.ts +++ b/src/schema/yaml-1.1/bool.ts @@ -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 } diff --git a/tests/doc/stringify.ts b/tests/doc/stringify.ts index 5e3f7b68..0ff20d58 100644 --- a/tests/doc/stringify.ts +++ b/tests/doc/stringify.ts @@ -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 = `[ @@ -645,9 +645,11 @@ describe('scalar styles', () => { False, false, FALSE, + FALse, Off, off, OFF, + OfF, y, Y, Yes, @@ -670,9 +672,11 @@ describe('scalar styles', () => { false, false, false, + 'FALse', false, false, false, + 'OfF', true, true, true,