Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: escape more yaml values (#33686)

Pavel Feldmanb40889d1a85e
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 fe0de8cb9e..3acf1dbb1a 100644
--- a/tests/page/page-aria-snapshot.spec.ts
+++ b/tests/page/page-aria-snapshot.spec.ts
@@ -464,6 +464,12 @@ it('should escape yaml text in text nodes', async ({ page }) => {
<details>
<summary>one: <a href="#">link1</a> "two <a href="#">link2</a> 'three <a href="#">link3</a> \`four</summary>
</details>
+ <ul>
+ <a href="#">one</a>,<a href="#">two</a>
+ (<a href="#">three</a>)
+ {<a href="#">four</a>}
+ [<a href="#">five</a>]
+ </ul>
`);
await checkAndMatchSnapshot(page.locator('body'), `
@@ -475,6 +481,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: "]"
`);
});