From e3c5986c5b85e5e91f6a9fb763bf4eb971b167d3 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Tue, 19 Nov 2024 17:09:49 -0800 Subject: [PATCH] cherry-pick(#33686): chore: escape more yaml values --- .../playwright-core/src/server/injected/yaml.ts | 2 +- tests/page/page-aria-snapshot.spec.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/playwright-core/src/server/injected/yaml.ts b/packages/playwright-core/src/server/injected/yaml.ts index 977591c1cc..e87c6706de 100644 --- a/packages/playwright-core/src/server/injected/yaml.ts +++ b/packages/playwright-core/src/server/injected/yaml.ts @@ -63,7 +63,7 @@ function yamlStringNeedsQuotes(str: string): boolean { return true; // Strings that start with a special indicator character need quotes - if (/^[&*].*/.test(str)) + if (/^[&*\],].*/.test(str)) return true; // Strings containing ':' followed by a space or at the end need quotes diff --git a/tests/page/page-aria-snapshot.spec.ts b/tests/page/page-aria-snapshot.spec.ts index a7937e9be5..6b37438419 100644 --- a/tests/page/page-aria-snapshot.spec.ts +++ b/tests/page/page-aria-snapshot.spec.ts @@ -465,6 +465,12 @@ it('should escape yaml text in text nodes', async ({ page }) => {
one: link1 "two link2 'three link3 \`four
+ `); await checkAndMatchSnapshot(page.locator('body'), ` @@ -476,6 +482,17 @@ it('should escape yaml text in text nodes', async ({ page }) => { - text: "'three" - link "link3" - text: "\`four" + - list: + - link "one" + - text: "," + - link "two" + - text: ( + - link "three" + - text: ") {" + - link "four" + - text: "} [" + - link "five" + - text: "]" `); });