diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-11-17 15:34:47 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-17 15:34:47 -0600 |
commit | 22aebdf5d41a3509cd6515ccf5edcdf33715a76d (patch) | |
tree | 824af410d147404d0a6dc0908cec85cc71df5bfd /components/net/data_loader.rs | |
parent | b3ad71353bf264770bf0b3a87b32d86928eb09d4 (diff) | |
parent | 913c874cb55fd0fdc9e8f3a4c34624cd015fac8a (diff) | |
download | servo-22aebdf5d41a3509cd6515ccf5edcdf33715a76d.tar.gz servo-22aebdf5d41a3509cd6515ccf5edcdf33715a76d.zip |
Auto merge of #14246 - emilio:servo-url, r=SimonSapin
Urlmageddon
<!-- Please describe your changes on the following line: -->
Still needs a bunch of code in net to be converted in order to get more
advantage of this for images and stuff, but meanwhile this should help quite a
bit with #13778.
Still wanted to get this in.
r? @SimonSapin
<!-- 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/14246)
<!-- Reviewable:end -->
Diffstat (limited to 'components/net/data_loader.rs')
-rw-r--r-- | components/net/data_loader.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/components/net/data_loader.rs b/components/net/data_loader.rs index 5380a87f828..19a6c92f0e2 100644 --- a/components/net/data_loader.rs +++ b/components/net/data_loader.rs @@ -9,8 +9,9 @@ use net_traits::LoadConsumer; use net_traits::ProgressMsg::{Done, Payload}; use resource_thread::{CancellationListener, send_error, start_sending_sniffed_opt}; use rustc_serialize::base64::FromBase64; +use servo_url::ServoUrl; use std::sync::Arc; -use url::{Position, Url}; +use url::Position; use url::percent_encoding::percent_decode; pub fn factory(load_data: LoadData, @@ -31,10 +32,10 @@ pub enum DecodeError { pub type DecodeData = (Mime, Vec<u8>); -pub fn decode(url: &Url) -> Result<DecodeData, DecodeError> { - assert!(url.scheme() == "data"); +pub fn decode(url: &ServoUrl) -> Result<DecodeData, DecodeError> { + assert_eq!(url.scheme(), "data"); // Split out content type and data. - let parts: Vec<&str> = url[Position::BeforePath..Position::AfterQuery].splitn(2, ',').collect(); + let parts: Vec<&str> = url.as_url().unwrap()[Position::BeforePath..Position::AfterQuery].splitn(2, ',').collect(); if parts.len() != 2 { return Err(DecodeError::InvalidDataUri); } @@ -61,7 +62,7 @@ pub fn decode(url: &Url) -> Result<DecodeData, DecodeError> { if is_base64 { // FIXME(#2909): It’s unclear what to do with non-alphabet characters, // but Acid 3 apparently depends on spaces being ignored. - bytes = bytes.into_iter().filter(|&b| b != ' ' as u8).collect::<Vec<u8>>(); + bytes = bytes.into_iter().filter(|&b| b != b' ').collect::<Vec<u8>>(); match bytes.from_base64() { Err(..) => return Err(DecodeError::NonBase64DataUri), Ok(data) => bytes = data, |