티스토리 수익 글 보기

티스토리 수익 글 보기

Whitelist accessibility attributes (aria-*, role, tabindex) by oomsveta · Pull Request #486 · lxml/lxml · GitHub
Skip to content

Whitelist accessibility attributes (aria-*, role, tabindex) – #486

Merged
scoder merged 2 commits into
lxml:masterfrom
oomsveta:safe-aria
Dec 17, 2025
Merged

Whitelist accessibility attributes (aria-*, role, tabindex)#486
scoder merged 2 commits into
lxml:masterfrom
oomsveta:safe-aria

Conversation

@oomsveta

Copy link
Copy Markdown
Contributor

Before this commit:

lxml.html.clean.Cleaner strips all ARIA attributes (e.g., aria-label, aria-hidden, role) by default. This is because they are not included in the “safe attributes” whitelist. This behavior caused sanitized HTML to lose semantic meaning for assistive technologies (screen readers), making the output non-compliant with WCAG standards.

After this commit:

ARIA attributes are added to defs.safe_attrs so the Cleaner will no longer filter them out. This change ensures that developers using lxml for sanitization will not accidentally strip accessibility features while maintaining protection against XSS.

oomsveta and others added 2 commits December 17, 2025 10:13
Before this commit:
`lxml.html.clean.Cleaner` strips all ARIA attributes (e.g., aria-label,
aria-hidden, role) by default. This is because they are not included in
the "safe attributes" whitelist.
This behavior caused sanitized HTML to lose semantic meaning for
assistive technologies (screen readers), making the output non-compliant
with WCAG standards.

After this commit:
ARIA attributes are added to `defs.safe_attrs` so the Cleaner will no
longer filter them out. This change ensures that developers using lxml
for sanitization will not accidentally strip accessibility features
while maintaining protection against XSS.

Bug report: 2136144
@scoder
scoder merged commit 4153564 into lxml:master Dec 17, 2025
74 checks passed
@scoder

scoder commented Dec 17, 2025

Copy link
Copy Markdown
Member

Thanks

robinwhittleton added a commit to robinwhittleton/lxml that referenced this pull request Mar 3, 2026
This was added in lxml#486, but was already in the set on line 49.
scoder pushed a commit that referenced this pull request Mar 27, 2026
This was added in #486, but was already in the set on line 49.
scoder pushed a commit that referenced this pull request Apr 17, 2026
Before this commit:
`lxml.html.clean.Cleaner` striped all ARIA attributes (e.g., aria-label, aria-hidden, role) by default.
This is because they were not included in the "safe attributes" whitelist.

This behavior caused sanitized HTML to lose semantic meaning for assistive technologies
(screen readers), making the output non-compliant with WCAG standards.

After this commit:
ARIA attributes are added to `defs.safe_attrs` so the Cleaner will no longer filter them out.
This change ensures that developers using lxml for sanitization will not accidentally strip
accessibility features while maintaining protection against XSS.

Closes https://bugs.launchpad.net/bugs/2136144
scoder pushed a commit that referenced this pull request Apr 17, 2026
This was added in #486, but was already in the set on line 49.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants