Repository navigation
fix(aria): quote YAML special scalars in aria snapshot values - #41590
Closed
Spoko Dev (spokodev) wants to merge 1 commit into
Closed
Spoko Dev (spokodev) wants to merge 1 commit into
Spoko Dev (spokodev) wants to merge 1 commit into
Conversation
The `~` null indicator and `.inf`/`.nan` floats were emitted unquoted, so a page whose accessible text is one of these tokens produced an aria snapshot that either failed to parse or round-tripped to a different string (e.g. `.inf` -> `Infinity`).
Contributor
|
Hi! Could you start with filing an issue about the bug you're facing? It's hard to understand the context of this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
yamlEscapeValueIfNeededdoes not quote the YAML null indicator~or the special float scalars.inf/.nan, so aria snapshots corrupt when a page's accessible text or attribute is literally one of those tokens.When such a value is emitted unquoted and then parsed back with the
yamllibrary (YAML 1.2 core schema), the parser reinterprets it:.inf-> the numberInfinity, so the text silently becomes"Infinity".nan->NaN~->null, which the aria snapshot parser then rejects ("value should be a string")The same applies to
.Inf,.INF,+.inf,.NaN, and so on. This breaksexpect(locator).toMatchAriaSnapshot()andlocator.ariaSnapshot()round-trips for a page showing, for example,.inf/.nanin a math or spreadsheet UI, or a~label. The existing code already quotesnull,true,.5,-.inf, and similar; only this family slipped through.Fix
Test
Added
tests/library/unit/aria-yaml.spec.ts: these tokens round-trip back to their original strings after escaping. It fails before the change (~-> null / parse error,.inf/.nan-> numbers) and passes after; common strings such ashello,button,path/toare not over-quoted.