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

fix(a11y-status): escape HTML in statuses #231

Merged
merged 2 commits into from
Oct 17, 2017
Merged

fix(a11y-status): escape HTML in statuses #231

merged 2 commits into from
Oct 17, 2017

Conversation

rgajrawala
Copy link
Contributor

@rgajrawala rgajrawala commented Oct 17, 2017

What/Why:
Potential XSS attack in generation of a11y status messages. Need to escape input before rendering those.

How:
Escape input by building the a11y status div using DOM API and fill in status message using textContent, which automatically escapes text (wanted to use innerText but it's not supported in Enzyme tests).

When using the DOM API, previous children will need to removed manually. I opted for using a loop and Node.removeChild over Node.innerHTML = '' because the former is more performant.

Checklist:

  • Documentation N/A
  • Tests
  • Ready to be merged>
  • Added myself to contributors table

@codecov-io
Copy link

codecov-io commented Oct 17, 2017

Codecov Report

Merging #231 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #231   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      4           
  Lines         271    277    +6     
  Branches       63     63           
=====================================
+ Hits          271    277    +6
Impacted Files Coverage Δ
src/set-a11y-status.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1385fc9...df3245d. Read the comment docs.

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for this! Very helpful 👍

@kentcdodds kentcdodds merged commit 880d1f5 into downshift-js:master Oct 17, 2017
@kentcdodds
Copy link
Member

This has been released. Everyone should upgrade to downshift@1.13.1 as soon as possible.

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.

3 participants