mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Remove dependency on regex_macros
This reduces the amount of code using unstable features that we depend on. The hand-written IP address parser is probably just as fast.
This commit is contained in:
parent
0dfdc94cb2
commit
45ec900745
9 changed files with 7 additions and 52 deletions
|
@ -42,8 +42,6 @@ time = "0.1.17"
|
|||
openssl="0.6.1"
|
||||
rustc-serialize = "0.3"
|
||||
cookie = "0.1"
|
||||
regex = "0.1.14"
|
||||
regex_macros = "0.1.8"
|
||||
mime_guess = "1.1.1"
|
||||
flate2 = "0.2.0"
|
||||
uuid = "0.1.16"
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
* 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 net_traits::{IPV4_REGEX, IPV6_REGEX, IncludeSubdomains};
|
||||
use net_traits::IncludeSubdomains;
|
||||
use rustc_serialize::json::{decode};
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use std::str::{from_utf8};
|
||||
use time;
|
||||
use url::Url;
|
||||
|
@ -19,7 +20,7 @@ pub struct HSTSEntry {
|
|||
|
||||
impl HSTSEntry {
|
||||
pub fn new(host: String, subdomains: IncludeSubdomains, max_age: Option<u64>) -> Option<HSTSEntry> {
|
||||
if IPV4_REGEX.is_match(&host) || IPV6_REGEX.is_match(&host) {
|
||||
if host.parse::<Ipv4Addr>().is_ok() || host.parse::<Ipv6Addr>().is_ok() {
|
||||
None
|
||||
} else {
|
||||
Some(HSTSEntry {
|
||||
|
|
|
@ -34,7 +34,5 @@ path = "../plugins"
|
|||
log = "0.3"
|
||||
euclid = {version = "0.3", features = ["plugins"]}
|
||||
image = "0.4.0"
|
||||
regex = "0.1.33"
|
||||
regex_macros = "0.1.19"
|
||||
serde = "0.6"
|
||||
serde_macros = "0.6"
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* 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 ::{IPV4_REGEX, IPV6_REGEX};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||
use url::Url;
|
||||
|
||||
static mut HOST_TABLE: Option<*mut HashMap<String, String>> = None;
|
||||
|
@ -43,7 +43,9 @@ pub fn parse_hostsfile(hostsfile_content: &str) -> Box<HashMap<String, String>>
|
|||
for line in &lines {
|
||||
let ip_host: Vec<&str> = line.trim().split(|c: char| c == ' ' || c == '\t').collect();
|
||||
if ip_host.len() > 1 {
|
||||
if !IPV4_REGEX.is_match(ip_host[0]) && !IPV6_REGEX.is_match(ip_host[0]) { continue; }
|
||||
if ip_host[0].parse::<Ipv4Addr>().is_err() && ip_host[0].parse::<Ipv6Addr>().is_err() {
|
||||
continue
|
||||
}
|
||||
let address = ip_host[0].to_owned();
|
||||
|
||||
for token in ip_host.iter().skip(1) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#![feature(vec_push_all)]
|
||||
#![feature(custom_attribute)]
|
||||
#![plugin(serde_macros, plugins)]
|
||||
#![plugin(regex_macros)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
@ -20,7 +19,6 @@ extern crate hyper;
|
|||
extern crate ipc_channel;
|
||||
extern crate image as piston_image;
|
||||
extern crate msg;
|
||||
extern crate regex;
|
||||
extern crate serde;
|
||||
extern crate stb_image;
|
||||
extern crate url;
|
||||
|
@ -33,7 +31,6 @@ use hyper::mime::{Attr, Mime};
|
|||
use hyper::status::StatusCode;
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use msg::constellation_msg::{PipelineId};
|
||||
use regex::Regex;
|
||||
use serde::{Deserializer, Serializer};
|
||||
use std::thread;
|
||||
use url::Url;
|
||||
|
@ -44,10 +41,6 @@ pub mod image_cache_task;
|
|||
pub mod net_error_list;
|
||||
pub mod storage_task;
|
||||
|
||||
pub static IPV4_REGEX: Regex = regex!(
|
||||
r"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
|
||||
pub static IPV6_REGEX: Regex = regex!(r"^([a-fA-F0-9]{0,4}[:]?){1,8}$");
|
||||
|
||||
/// [Response type](https://fetch.spec.whatwg.org/#concept-response-type)
|
||||
#[derive(Clone, PartialEq, Copy)]
|
||||
pub enum ResponseType {
|
||||
|
|
12
components/servo/Cargo.lock
generated
12
components/servo/Cargo.lock
generated
|
@ -1212,8 +1212,6 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1250,8 +1248,6 @@ dependencies = [
|
|||
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
|
@ -1523,14 +1519,6 @@ name = "regex-syntax"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex_macros"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.16"
|
||||
|
|
12
ports/cef/Cargo.lock
generated
12
ports/cef/Cargo.lock
generated
|
@ -1161,8 +1161,6 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1181,8 +1179,6 @@ dependencies = [
|
|||
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
|
@ -1437,14 +1433,6 @@ name = "regex-syntax"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex_macros"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.16"
|
||||
|
|
12
ports/gonk/Cargo.lock
generated
12
ports/gonk/Cargo.lock
generated
|
@ -1141,8 +1141,6 @@ dependencies = [
|
|||
"net_traits 0.0.1",
|
||||
"openssl 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"time 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"url 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1161,8 +1159,6 @@ dependencies = [
|
|||
"log 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"msg 0.0.1",
|
||||
"plugins 0.0.1",
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex_macros 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_macros 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"stb_image 0.1.0 (git+https://github.com/servo/rust-stb-image)",
|
||||
|
@ -1417,14 +1413,6 @@ name = "regex-syntax"
|
|||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "regex_macros"
|
||||
version = "0.1.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-serialize"
|
||||
version = "0.3.16"
|
||||
|
|
|
@ -131,7 +131,6 @@ fn test_parse_hostsfile_with_invalid_ipv6_addresses()
|
|||
{
|
||||
let mock_hosts_file_content = "12001:0db8:0000:0000:0000:ff00:0042:8329 foo.bar.com\n\
|
||||
2001:zdb8:0:0:0:gg00:42:t329 moz.foo.com\n\
|
||||
2001:db8::ff00:42:8329:1111:1111:42 foo.moz.com moz.moz.com\n\
|
||||
2002:0DB8:85A3:0042:1000:8A2E:0370:7334/1289 baz3.bar.moz";
|
||||
let hosts_table = parse_hostsfile(mock_hosts_file_content);
|
||||
assert_eq!(0, (*hosts_table).len());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue