mirror of
https://github.com/servo/servo.git
synced 2025-08-02 04:00:32 +01:00
Auto merge of #16063 - methyl:image-usemap-panics, r=nox
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 -->
This commit is contained in:
commit
69eda6a60c
3 changed files with 33 additions and 0 deletions
|
@ -423,6 +423,11 @@ impl HTMLImageElement {
|
|||
};
|
||||
|
||||
let value = usemap_attr.value();
|
||||
|
||||
if value.len() == 0 || !value.is_char_boundary(1) {
|
||||
return None
|
||||
}
|
||||
|
||||
let (first, last) = value.split_at(1);
|
||||
|
||||
if first != "#" || last.len() == 0 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue