Skip to content

Commit

Permalink
fix(aria): escape leading dash in property values (#34227)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored Jan 7, 2025
1 parent d2af88c commit 9514f0f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/playwright-core/src/server/injected/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ function yamlStringNeedsQuotes(str: string): boolean {
if (/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(str))
return true;

// Strings starting with '-' followed by a space need quotes
if (/^-\s/.test(str))
// Strings starting with '-' need quotes
if (/^-/.test(str))
return true;

// Strings containing ':' or '\n' followed by a space or at the end need quotes
Expand Down
3 changes: 3 additions & 0 deletions tests/page/page-aria-snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ it('should escape special yaml values', async ({ page }) => {
<a href="#">null</a>NULL
<a href="#">123</a>123
<a href="#">-1.2</a>-1.2
<a href="#">-</a>-
<input type=text value="555">
`);

Expand All @@ -573,6 +574,8 @@ it('should escape special yaml values', async ({ page }) => {
- text: "123"
- link "-1.2"
- text: "-1.2"
- link "-"
- text: "-"
- textbox: "555"
`);
});

0 comments on commit 9514f0f

Please sign in to comment.