mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Urlmageddon: Use refcounted urls more often.
This commit is contained in:
parent
f14e7339b5
commit
913c874cb5
161 changed files with 1044 additions and 718 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue