mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove unused content blocker code.
I don't know what it is for, so I believe it would be better to remove it entirely until and unless we start using it.
This commit is contained in:
parent
e3cc2dd283
commit
5a61d8b2ea
7 changed files with 0 additions and 118 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1670,7 +1670,6 @@ name = "net"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"brotli 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"brotli 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"content-blocker 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"devtools_traits 0.0.1",
|
"devtools_traits 0.0.1",
|
||||||
"flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1678,7 +1677,6 @@ dependencies = [
|
||||||
"hyper_serde 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"hyper_serde 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"immeta 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
"immeta 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"ipc-channel 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"mime 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
|
|
@ -11,7 +11,6 @@ path = "lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
brotli = "1.0.6"
|
brotli = "1.0.6"
|
||||||
content-blocker = "0.2.3"
|
|
||||||
cookie = "0.2.5"
|
cookie = "0.2.5"
|
||||||
devtools_traits = {path = "../devtools_traits"}
|
devtools_traits = {path = "../devtools_traits"}
|
||||||
flate2 = "0.2.0"
|
flate2 = "0.2.0"
|
||||||
|
@ -19,7 +18,6 @@ hyper = "0.9.9"
|
||||||
hyper_serde = "0.5"
|
hyper_serde = "0.5"
|
||||||
immeta = "0.3.1"
|
immeta = "0.3.1"
|
||||||
ipc-channel = "0.7"
|
ipc-channel = "0.7"
|
||||||
lazy_static = "0.2"
|
|
||||||
log = "0.3.5"
|
log = "0.3.5"
|
||||||
matches = "0.1"
|
matches = "0.1"
|
||||||
mime = "0.2.1"
|
mime = "0.2.1"
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use content_blocker_parser::{RuleList, parse_list};
|
|
||||||
use servo_config::resource_files::read_resource_file;
|
|
||||||
use std::str;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
pub static ref BLOCKED_CONTENT_RULES: Arc<Option<RuleList>> = Arc::new(create_rule_list());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn create_rule_list() -> Option<RuleList> {
|
|
||||||
let contents = match read_resource_file("blocked-content.json") {
|
|
||||||
Ok(c) => c,
|
|
||||||
Err(_) => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let str_contents = match str::from_utf8(&contents) {
|
|
||||||
Ok(c) => c,
|
|
||||||
Err(_) => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let list = match parse_list(&str_contents) {
|
|
||||||
Ok(l) => l,
|
|
||||||
Err(_) => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(list)
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use brotli::Decompressor;
|
use brotli::Decompressor;
|
||||||
use connector::{Connector, create_http_connector};
|
use connector::{Connector, create_http_connector};
|
||||||
use content_blocker_parser::RuleList;
|
|
||||||
use cookie;
|
use cookie;
|
||||||
use cookie_storage::CookieStorage;
|
use cookie_storage::CookieStorage;
|
||||||
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest};
|
use devtools_traits::{ChromeToDevtoolsControlMsg, DevtoolsControlMsg, HttpRequest as DevtoolsHttpRequest};
|
||||||
|
@ -70,7 +69,6 @@ pub struct HttpState {
|
||||||
pub hsts_list: Arc<RwLock<HstsList>>,
|
pub hsts_list: Arc<RwLock<HstsList>>,
|
||||||
pub cookie_jar: Arc<RwLock<CookieStorage>>,
|
pub cookie_jar: Arc<RwLock<CookieStorage>>,
|
||||||
pub auth_cache: Arc<RwLock<AuthCache>>,
|
pub auth_cache: Arc<RwLock<AuthCache>>,
|
||||||
pub blocked_content: Arc<Option<RuleList>>,
|
|
||||||
pub connector_pool: Arc<Pool<Connector>>,
|
pub connector_pool: Arc<Pool<Connector>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +78,6 @@ impl HttpState {
|
||||||
hsts_list: Arc::new(RwLock::new(HstsList::new())),
|
hsts_list: Arc::new(RwLock::new(HstsList::new())),
|
||||||
cookie_jar: Arc::new(RwLock::new(CookieStorage::new(150))),
|
cookie_jar: Arc::new(RwLock::new(CookieStorage::new(150))),
|
||||||
auth_cache: Arc::new(RwLock::new(AuthCache::new())),
|
auth_cache: Arc::new(RwLock::new(AuthCache::new())),
|
||||||
blocked_content: Arc::new(None),
|
|
||||||
connector_pool: create_http_connector(certificate_path),
|
connector_pool: create_http_connector(certificate_path),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#![feature(mpsc_select)]
|
#![feature(mpsc_select)]
|
||||||
|
|
||||||
extern crate brotli;
|
extern crate brotli;
|
||||||
extern crate content_blocker as content_blocker_parser;
|
|
||||||
extern crate cookie as cookie_rs;
|
extern crate cookie as cookie_rs;
|
||||||
extern crate devtools_traits;
|
extern crate devtools_traits;
|
||||||
extern crate flate2;
|
extern crate flate2;
|
||||||
|
@ -15,7 +14,6 @@ extern crate hyper;
|
||||||
extern crate hyper_serde;
|
extern crate hyper_serde;
|
||||||
extern crate immeta;
|
extern crate immeta;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
#[macro_use] extern crate lazy_static;
|
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
#[macro_use] #[no_link] extern crate matches;
|
#[macro_use] #[no_link] extern crate matches;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
@ -46,7 +44,6 @@ extern crate websocket;
|
||||||
mod blob_loader;
|
mod blob_loader;
|
||||||
mod chrome_loader;
|
mod chrome_loader;
|
||||||
mod connector;
|
mod connector;
|
||||||
mod content_blocker;
|
|
||||||
pub mod cookie;
|
pub mod cookie;
|
||||||
pub mod cookie_storage;
|
pub mod cookie_storage;
|
||||||
mod data_loader;
|
mod data_loader;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
//! A thread that takes a URL and streams back the binary data.
|
//! A thread that takes a URL and streams back the binary data.
|
||||||
use connector::{Connector, create_http_connector};
|
use connector::{Connector, create_http_connector};
|
||||||
use content_blocker::BLOCKED_CONTENT_RULES;
|
|
||||||
use cookie;
|
use cookie;
|
||||||
use cookie_rs;
|
use cookie_rs;
|
||||||
use cookie_storage::CookieStorage;
|
use cookie_storage::CookieStorage;
|
||||||
|
@ -324,7 +323,6 @@ impl CoreResourceManager {
|
||||||
hsts_list: group.hsts_list.clone(),
|
hsts_list: group.hsts_list.clone(),
|
||||||
cookie_jar: group.cookie_jar.clone(),
|
cookie_jar: group.cookie_jar.clone(),
|
||||||
auth_cache: group.auth_cache.clone(),
|
auth_cache: group.auth_cache.clone(),
|
||||||
blocked_content: BLOCKED_CONTENT_RULES.clone(),
|
|
||||||
// FIXME(#15694): use group.connector.clone() instead.
|
// FIXME(#15694): use group.connector.clone() instead.
|
||||||
connector_pool: create_http_connector("certs"),
|
connector_pool: create_http_connector("certs"),
|
||||||
};
|
};
|
||||||
|
|
|
@ -1118,78 +1118,3 @@ fn test_auth_ui_needs_www_auth() {
|
||||||
|
|
||||||
assert_eq!(response.status.unwrap(), StatusCode::Unauthorized);
|
assert_eq!(response.status.unwrap(), StatusCode::Unauthorized);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_content_blocked() {
|
|
||||||
let handler = move |_: HyperRequest, response: HyperResponse| {
|
|
||||||
response.send(b"Yay!").unwrap();
|
|
||||||
};
|
|
||||||
let (mut server, url) = make_server(handler);
|
|
||||||
|
|
||||||
let url_filter = url.as_str().replace("http://", "https?://");
|
|
||||||
let blocked_content_list = format!("[{{ \
|
|
||||||
\"trigger\": {{ \"url-filter\": \"{}\" }}, \
|
|
||||||
\"action\": {{ \"type\": \"block\" }} \
|
|
||||||
}}]", url_filter);
|
|
||||||
|
|
||||||
let mut context = new_fetch_context(None);
|
|
||||||
context.state.blocked_content = Arc::new(Some(parse_list(&blocked_content_list).unwrap()));
|
|
||||||
|
|
||||||
let request = Request::from_init(RequestInit {
|
|
||||||
url: url.clone(),
|
|
||||||
method: Method::Get,
|
|
||||||
body: None,
|
|
||||||
destination: Destination::Document,
|
|
||||||
origin: url.clone(),
|
|
||||||
.. RequestInit::default()
|
|
||||||
});
|
|
||||||
|
|
||||||
let response = fetch_with_context(request, &context);
|
|
||||||
|
|
||||||
let _ = server.close();
|
|
||||||
|
|
||||||
// TODO(#14307): this should fail.
|
|
||||||
assert!(response.status.unwrap().is_success());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_cookies_blocked() {
|
|
||||||
let handler = move |request: HyperRequest, response: HyperResponse| {
|
|
||||||
assert_eq!(request.headers.get::<CookieHeader>(), None);
|
|
||||||
response.send(b"hi").unwrap();
|
|
||||||
};
|
|
||||||
let (mut server, url) = make_server(handler);
|
|
||||||
|
|
||||||
let url_filter = url.as_str().replace("http://", "https?://");
|
|
||||||
let blocked_content_list = format!("[{{ \
|
|
||||||
\"trigger\": {{ \"url-filter\": \"{}\" }}, \
|
|
||||||
\"action\": {{ \"type\": \"block-cookies\" }} \
|
|
||||||
}}]", url_filter);
|
|
||||||
|
|
||||||
let mut context = new_fetch_context(None);
|
|
||||||
context.state.blocked_content = Arc::new(Some(parse_list(&blocked_content_list).unwrap()));
|
|
||||||
{
|
|
||||||
let mut cookie_jar = context.state.cookie_jar.write().unwrap();
|
|
||||||
let cookie = Cookie::new_wrapped(
|
|
||||||
CookiePair::new("mozillaIs".to_owned(), "theBest".to_owned()),
|
|
||||||
&url,
|
|
||||||
CookieSource::HTTP
|
|
||||||
).unwrap();
|
|
||||||
cookie_jar.push(cookie, &url, CookieSource::HTTP);
|
|
||||||
}
|
|
||||||
|
|
||||||
let request = Request::from_init(RequestInit {
|
|
||||||
url: url.clone(),
|
|
||||||
method: Method::Get,
|
|
||||||
body: None,
|
|
||||||
destination: Destination::Document,
|
|
||||||
origin: url.clone(),
|
|
||||||
.. RequestInit::default()
|
|
||||||
});
|
|
||||||
|
|
||||||
let response = fetch_with_context(request, &context);
|
|
||||||
|
|
||||||
let _ = server.close();
|
|
||||||
|
|
||||||
assert!(response.status.unwrap().is_success());
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue