Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isIconLigature fails on leading invisible character #3913

Closed
1 task done
SirUppyPancakes opened this issue Feb 13, 2023 · 4 comments · Fixed by #4102
Closed
1 task done

isIconLigature fails on leading invisible character #3913

SirUppyPancakes opened this issue Feb 13, 2023 · 4 comments · Fixed by #4102
Labels
color contrast Color contrast issues commons Issues in the common code (lib/commons) fix Bug fixes pr A pr has been created for the issue
Milestone

Comments

@SirUppyPancakes
Copy link

SirUppyPancakes commented Feb 13, 2023

Product

axe-core

Product Version

4.6.3

Latest Version

  • I have tested the issue with the latest version of the product

Issue Description

Expectation

Expected axe-core to be able to handle any valid HTML (the HTML in this case is 100% valid according to the W3C validator)

Actual

The isIconLigature function fails to consider invisible characters at the start of the input, resulting in a SupportError being thrown.

How to Reproduce

Project which reproduces the issue:
axe-core-invisible-issue.zip

Steps:

  1. Run npm install
  2. Start a server to serve the html file (I used the html-server npm package, for example) or simply open the html file in a browser
  3. Optionally put some breakpoints (in node_modules/axe-core/axe.js) to observe the exact source of the issue, on the following lines:
    • 11378 var compareData = new Uint32Array(canvasContext.getImageData(0, 0, width, fontSize).data.buffer);
    • 11379 if (!compareData.some(function(pixel) {
    • 22005 reject(new SupportError({

After hitting the break point right before isIconLigature calls canvasContext.getImageData, you'll be able to see that width and fontSize have been determined to be NaN and Infinity which are invalid parameters for this function, causing it to throw an exception and result in the SupportError being generated. This happens because the first character in the link content of my HTML in this case is [U+2069] which is an invisible character relating to the left-to-right or right-to-left nature of the text (we ran into this issue when checking one of our Arabic-translated files).

Would it be possible to change isIconLigature to look for the first visible character? I suppose there would also need to be a case to handle if there isn't any visible characters in the span as well...

@SirUppyPancakes SirUppyPancakes added the ungroomed Ticket needs a maintainer to prioritize and label label Feb 13, 2023
@straker
Copy link
Contributor

straker commented Feb 13, 2023

Thanks for the issue. For security reasons I can't open a zip file. However, thanks to the description I can reproduce this on my end using the HTML string ⁩Hello World.

Note for future self. We should be able to fix this by passing the string through removeUnicode first before trying to get the first character. We should also add a guard against 0 for width so we don't throw an error.

@straker straker added fix Bug fixes commons Issues in the common code (lib/commons) color contrast Color contrast issues and removed ungroomed Ticket needs a maintainer to prioritize and label labels Feb 13, 2023
@SirUppyPancakes
Copy link
Author

Thanks! For future reference for myself, what would have been a preferable way to share a test project? A gist maybe?

@straker
Copy link
Contributor

straker commented Feb 13, 2023

A gist or HTML snippet work best.

@padmavemulapati
Copy link

Validated with the latest axe-core develop branch code base, not seeing any failure with the ligature icon on invisible charecters,
for ex: <main> <a href="https://www.google.com">⁩البطاطس</a > </main>

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
color contrast Color contrast issues commons Issues in the common code (lib/commons) fix Bug fixes pr A pr has been created for the issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants