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

Correct handling of whitespace in base64 URLs #24865

Closed
wants to merge 5 commits into from
Closed

Conversation

@pshaughn
Copy link
Member

pshaughn commented Nov 25, 2019

Whitespace handling in base64 url parsing now treats tabs, form-feeds, and linefeeds the same way it treats regular spaces


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix (part of) #2909
  • There are tests for these changes OR
  • These changes do not require tests because ___
@highfive
Copy link

highfive commented Nov 25, 2019

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @jdm (or someone else) soon.

@highfive
Copy link

highfive commented Nov 25, 2019

Heads up! This PR modifies the following files:

Copy link
Member

jdm left a comment

Good find on the data url decoding problems!

bytes = bytes
.into_iter()
.filter(|&b| b != b' ')
.filter(|&b| b != b' ' && b != b'\x0C' && b != b'\n' && b != b'\r' && b != b'\t')

This comment has been minimized.

@jdm

jdm Nov 25, 2019

Member

While it's logical to extend the existing code here, we should honour SimonSapin's request in #2909 (comment) to make use of the data-url crate and replace all of this decoding code if possible.

We should be able to use DataUrl::process(url.as_str()) and return the value of decode_to_vec() along with the url's mime_type() value. We'll need to add data-url as a new dependency in components/net/Cargo.toml as well.

This comment has been minimized.

@pshaughn

pshaughn Nov 25, 2019

Author Member

Will do! I've never added a Cargo dependency before, but I'll have to sooner or later and I may as well start with this one!

@pshaughn
Copy link
Member Author

pshaughn commented Nov 26, 2019

Now using data-url's version of forgiving base64 decoding, but still doing the rest of the MIME parse within data_loader.rs, as suggested in #2909 (comment). This is a full fix for #2909 as far as WPT tests are concerned, but integrating with the full data-url class eventually would be nice.

@SimonSapin
Copy link
Member

SimonSapin commented Nov 26, 2019

Could you squash your commits into one? Assuming https://github.com/servo/servo is your origin remote, that would be something like git fetch origin && git rebase -i origin/master. Or I can do it for you prefer.

@pshaughn
Copy link
Member Author

pshaughn commented Nov 26, 2019

@SimonSapin : Is there a way to do that within this pull request, or should I make a new pull request with the merged commit?

@pshaughn
Copy link
Member Author

pshaughn commented Nov 26, 2019

#24870 is the commit-squashed version of this, sorry for the mess

@pshaughn pshaughn closed this Nov 26, 2019
bors-servo added a commit that referenced this pull request Nov 27, 2019
Fix #2909 (squashed version of PR #24865)

<!-- Please describe your changes on the following line: -->
Now using data-url::forgiving_base64 instead of base64, this fixes all the fetch/data-urls/base64.* tests.

---
<!-- 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 do not quite fix yet #2909

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
bors-servo added a commit that referenced this pull request Nov 27, 2019
Fix #2909 (squashed version of PR #24865)

<!-- Please describe your changes on the following line: -->
Now using data-url::forgiving_base64 instead of base64, this fixes all the fetch/data-urls/base64.* tests.

---
<!-- 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 do not quite fix yet #2909

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because ___

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.