axe-core icon indicating copy to clipboard operation
axe-core copied to clipboard

Option to truncate excessively large `.html` in results

Open stephenmathieson opened this issue 1 year ago • 2 comments

Product

axe-core

Feature Description

When analyzing a axe Watcher results in prod, we noticed we have a few excessively large datums (>1MB). This is preventing us from migrating result data to a different (much faster data store).

After digging further, it was noticed that this is due to axe-core including the element in violation's outerHTML (eg .violations[x].nodes[y].html) and its related node's outerHTML (.violations[x].nodes[y].relatedNodes[z].html). Consider the following snippet:

<img class="foo" src="data:png,base64, EXTREMELY LARGE IMAGE CONVERTED TO BASE64" />

It appears axe-core is already truncating some parts (children) of the element's HTML, but not the element itself.

An option similar to axe.configure({ noHtml: true }) which causes axe-core to truncate ALL HTML snippets would be extremely helpful.

stephenmathieson avatar Jul 25 '24 18:07 stephenmathieson

@stephenmathieson Thanks for the suggestion. That's definitely a problem we should find a solution to. I'm not sure whether it should be a separate option. Axe-core truncates HTML snippets to prevent this problem. I think what we might want to do also put limits on attributes, both on the length of an attribute value, and of the number of attributes.

I'll bring this up with the team to come up with a solution.

WilcoFiers avatar Jul 29 '24 16:07 WilcoFiers

Talked about this, we agree this should happen. Will be in 4.11 / 5.0, won't do this in a patch.

We think the best way to do this is to:

  1. Look at each attribute, if any are too long replace the value with "..."
  2. If this results in a string that is overall still too long, start removing attributes and ad "..." at the end of the tag.
  3. If this is still too longer (very long custom elm) we take only the first X characters and truncate with "..." at the end.

WilcoFiers avatar Sep 12 '24 15:09 WilcoFiers

Closed by #4796

straker avatar Nov 05 '25 15:11 straker