aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/net/Cargo.toml2
-rw-r--r--components/net/hsts.rs5
-rw-r--r--components/net_traits/Cargo.toml2
-rw-r--r--components/net_traits/hosts.rs6
-rw-r--r--components/net_traits/lib.rs7
-rw-r--r--components/servo/Cargo.lock12
-rw-r--r--ports/cef/Cargo.lock12
-rw-r--r--ports/gonk/Cargo.lock12
-rw-r--r--tests/unit/net/resource_task.rs8
9 files changed, 9 insertions, 57 deletions
diff --git a/components/net/Cargo.toml b/components/net/Cargo.toml
index 9d3e91631a6..3c88b61626e 100644
--- a/components/net/Cargo.toml
+++ b/components/net/Cargo.toml
@@ -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"
diff --git a/components/net/hsts.rs b/components/net/hsts.rs
index cfa5b981428..795c1cae079 100644
--- a/components/net/hsts.rs
+++ b/components/net/hsts.rs
@@ -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 {
diff --git a/components/net_traits/Cargo.toml b/components/net_traits/Cargo.toml
index 1ab4fe2e341..1cbf7313a65 100644
--- a/components/net_traits/Cargo.toml
+++ b/components/net_traits/Cargo.toml
@@ -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"
diff --git a/components/net_traits/hosts.rs b/components/net_traits/hosts.rs
index b4c7cf560e4..a5e35f8220b 100644
--- a/components/net_traits/hosts.rs
+++ b/components/net_traits/hosts.rs
@@ -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) {
diff --git a/components/net_traits/lib.rs b/components/net_traits/lib.rs
index f5e70489fd4..3a317c23d96 100644
--- a/components/net_traits/lib.rs
+++ b/components/net_traits/lib.rs
@@ -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}(/\d{1,3})?$");
-
/// [Response type](https://fetch.spec.whatwg.org/#concept-response-type)
#[derive(Clone, PartialEq, Copy)]
pub enum ResponseType {
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 4a2e4756464..80bf3d0e9c2 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -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)",
@@ -1524,14 +1520,6 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 69e9e27438e..e71bd53f022 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -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)",
@@ -1438,14 +1434,6 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 61b6e4167fe..c4c3a09a82b 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -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)",
@@ -1418,14 +1414,6 @@ 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"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/tests/unit/net/resource_task.rs b/tests/unit/net/resource_task.rs
index c72dc66ba22..b630306ec36 100644
--- a/tests/unit/net/resource_task.rs
+++ b/tests/unit/net/resource_task.rs
@@ -121,12 +121,9 @@ fn test_parse_hostsfile_with_valid_ipv6_addresses()
0000:0000:0000:0000:0000:0000:0000:0001 bar.moz.com\n\
::1 foo.bar.baz baz.foo.com\n\
2001:0DB8:85A3:0042:1000:8A2E:0370:7334 baz.bar.moz\n\
- 2002:0DB8:85A3:0042:1000:8A2E:0370:7334/96 baz2.bar.moz\n\
- 2002:0DB8:85A3:0042:1000:8A2E:0370:7334/128 baz3.bar.moz\n\
- :: unspecified.moz.com\n\
- ::/128 unspecified.address.com";
+ :: unspecified.moz.com";
let hosts_table = parse_hostsfile(mock_hosts_file_content);
- assert_eq!(12, (*hosts_table).len());
+ assert_eq!(9, (*hosts_table).len());
}
#[test]
@@ -134,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());