fix(yaml): escape to disambiguate yaml arrays (#34096)
This commit is contained in:
parent
ec1d3313c3
commit
6505a3e34c
|
|
@ -82,6 +82,10 @@ function yamlStringNeedsQuotes(str: string): boolean {
|
||||||
if (/[{}`]/.test(str))
|
if (/[{}`]/.test(str))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// YAML array starts with [
|
||||||
|
if (/^\[/.test(str))
|
||||||
|
return true;
|
||||||
|
|
||||||
// Non-string types recognized by YAML
|
// 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;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -482,6 +482,7 @@ it('should escape yaml text in text nodes', async ({ page }) => {
|
||||||
{<a href="#">four</a>}
|
{<a href="#">four</a>}
|
||||||
[<a href="#">five</a>]
|
[<a href="#">five</a>]
|
||||||
</ul>
|
</ul>
|
||||||
|
<div>[Select all]</div>
|
||||||
`);
|
`);
|
||||||
|
|
||||||
await checkAndMatchSnapshot(page.locator('body'), `
|
await checkAndMatchSnapshot(page.locator('body'), `
|
||||||
|
|
@ -504,6 +505,7 @@ it('should escape yaml text in text nodes', async ({ page }) => {
|
||||||
- text: "} ["
|
- text: "} ["
|
||||||
- link "five"
|
- link "five"
|
||||||
- text: "]"
|
- text: "]"
|
||||||
|
- text: "[Select all]"
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue