From 30acc8ae8f41d2afecee7be2a6e4f436f05fdc00 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 6 Jan 2025 16:30:16 -0800 Subject: [PATCH] fix(aria): escape leading dash in property values --- packages/playwright-core/src/server/injected/yaml.ts | 2 +- tests/page/page-aria-snapshot.spec.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/playwright-core/src/server/injected/yaml.ts b/packages/playwright-core/src/server/injected/yaml.ts index a9365c15bd..a5ace4015e 100644 --- a/packages/playwright-core/src/server/injected/yaml.ts +++ b/packages/playwright-core/src/server/injected/yaml.ts @@ -59,7 +59,7 @@ function yamlStringNeedsQuotes(str: string): boolean { return true; // Strings starting with '-' followed by a space need quotes - if (/^-\s/.test(str)) + if (/^-/.test(str)) return true; // Strings containing ':' or '\n' 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 1dafe14fa7..b7bb77091a 100644 --- a/tests/page/page-aria-snapshot.spec.ts +++ b/tests/page/page-aria-snapshot.spec.ts @@ -555,6 +555,7 @@ it('should escape special yaml values', async ({ page }) => { nullNULL 123123 -1.2-1.2 + -- `); @@ -573,6 +574,8 @@ it('should escape special yaml values', async ({ page }) => { - text: "123" - link "-1.2" - text: "-1.2" + - link "-" + - text: "-" - textbox: "555" `); });