Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/isomorphic/yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ function yamlStringNeedsQuotes(str: string): boolean {
return true;

// Non-string types recognized by YAML
if (!isNaN(Number(str)) || ['y', 'n', 'yes', 'no', 'true', 'false', 'on', 'off', 'null'].includes(str.toLowerCase()))
if (!isNaN(Number(str)) || ['y', 'n', 'yes', 'no', 'true', 'false', 'on', 'off', 'null', '~'].includes(str.toLowerCase()))
return true;

// YAML special float values: .inf, -.inf, .nan and their case variants
if (/^[-+]?\.(inf|nan)$/i.test(str))
return true;

return false;
Expand Down
12 changes: 11 additions & 1 deletion tests/page/page-aria-snapshot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,9 @@ it('should escape special yaml characters', async ({ page }) => {
`);
});

it('should escape special yaml values', async ({ page }) => {
it('should escape special yaml values', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/43451' },
}, async ({ page }) => {
await page.setContent(`
<a href="#">true</a>False
<a href="#">NO</a>yes
Expand All @@ -658,6 +660,8 @@ it('should escape special yaml values', async ({ page }) => {
<a href="#">123</a>123
<a href="#">-1.2</a>-1.2
<a href="#">-</a>-
<a href="#">~</a>~
<a href="#">.inf</a>.NaN
<input type=text value="555">
`);

Expand Down Expand Up @@ -686,6 +690,12 @@ it('should escape special yaml values', async ({ page }) => {
- link "-":
- /url: "#"
- text: "-"
- link "~":
- /url: "#"
- text: "~"
- link ".inf":
- /url: "#"
- text: ".NaN"
- textbox: "555"
`);
});
Expand Down