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

Panic when usemap attribute is empty / starts with multibyte character #15883

Closed
Ms2ger opened this issue Mar 9, 2017 · 0 comments
Closed

Panic when usemap attribute is empty / starts with multibyte character #15883

Ms2ger opened this issue Mar 9, 2017 · 0 comments

Comments

@Ms2ger
Copy link
Contributor

@Ms2ger Ms2ger commented Mar 9, 2017

<!DOCTYPE html>
<img usemap>
<script>
document.querySelector("img").dispatchEvent(new Event("click"));
</script>

panics with byte index 1 is out of bounds of `` at the split_at call in HTMLImageElement::areas.

<img usemap=&#x1F4A9;>

yields

byte index 1 is not a char boundary; it is inside '💩' (bytes 0..4) of `💩`

I don't know if there's a great way to check that this code actually works, but I think we should still add web-platform-tests (see tests/wpt/README.md) to check that that panics are gone.

notriddle added a commit that referenced this issue Mar 25, 2017
bors-servo added a commit that referenced this issue Mar 25, 2017
Avoid panics for empty or multibyte image usemap

<!-- Please describe your changes on the following line: -->
Some check were added to make sure we can call `split_at` with no risk of panics (when value is empty or the first char is multibyte).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15883 (github issue number if applicable).
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16063)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Apr 12, 2017
Avoid panics for empty or multibyte image usemap

<!-- Please describe your changes on the following line: -->
Some check were added to make sure we can call `split_at` with no risk of panics (when value is empty or the first char is multibyte).

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #15883 (github issue number if applicable).
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16063)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.