Skip to content

Commit

Permalink
chore: escape more yaml values (#33686)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Nov 20, 2024
1 parent 7f7b440 commit b40889d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/playwright-core/src/server/injected/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/page/page-aria-snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'), `
Expand All @@ -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: "]"
`);
});

Expand Down

0 comments on commit b40889d

Please sign in to comment.