Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.0, rewrite the data structure and API #176

Merged
merged 89 commits into from
Apr 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
83f4b9e
Split IDNA into a separate crate.
SimonSapin Mar 30, 2016
e0e60e9
IDNA: One test in the test harness per test case.
SimonSapin Mar 30, 2016
46acea9
Make it possible to define new encode sets in other crates.
SimonSapin Dec 4, 2015
87ee434
Define encode sets based on another set.
SimonSapin Dec 4, 2015
4ec32fa
Remove the HTTP_VALUE encode set. It can be defined in another crate.
SimonSapin Dec 4, 2015
9e759f1
Rewrite ALL THE THINGS!
SimonSapin Dec 9, 2015
2972218
Remove the dependency on uuid.
SimonSapin Feb 8, 2016
162e23f
Add URL slicing/indexing by component.
SimonSapin Feb 8, 2016
fa70482
Add stubs with partial implementation for the WebIDL API.
SimonSapin Feb 8, 2016
46d9fc9
Shorter Cargo.toml syntax.
SimonSapin Feb 8, 2016
b6686eb
serde_serialization -> serde
SimonSapin Feb 8, 2016
7517c8d
Make rustc-serialize an optional dependency.
SimonSapin Feb 8, 2016
7881aa5
Rename *{Start,End} posititons to {Before,After}*
SimonSapin Feb 9, 2016
a880bd3
Replace from_hex() with char::to_digit(16)
SimonSapin Feb 9, 2016
6db8b84
Make percent-decoding an iterator.
SimonSapin Feb 9, 2016
a3210b9
Make percent-encoding an iterator.
SimonSapin Feb 9, 2016
6fadafa
Add percent-encoding convienience wrappers.
SimonSapin Feb 9, 2016
1c9fb2f
Update tests from https://github.com/w3c/web-platform-tests/blob/mast…
SimonSapin Feb 10, 2016
f59870f
Remove Url::has_host
SimonSapin Feb 11, 2016
42b57d3
Remove unused ParseError variants
SimonSapin Feb 12, 2016
194da72
Make context a field of Parser.
SimonSapin Feb 11, 2016
31bde79
Remove the redundant is_relative field.
SimonSapin Feb 15, 2016
5364f2b
Add Url::domain and Url::ip_address
SimonSapin Feb 15, 2016
1afe54f
Implement ToSocketAddrs
SimonSapin Feb 15, 2016
21db81f
Remove Url::ip_address for now
SimonSapin Feb 15, 2016
1a22a90
Add Unicode and ASCII serializations of origins
SimonSapin Feb 16, 2016
8eba0ce
Test WebIdl::origin
SimonSapin Feb 16, 2016
44b601b
Add a fragment setter
SimonSapin Feb 11, 2016
0ac1ac5
Add a query setter.
SimonSapin Feb 12, 2016
ec1e55d
Make Url::parse_with usable. (EncodingOverride is private.)
SimonSapin Feb 19, 2016
0e5e27c
Add Origin::is_tuple
SimonSapin Feb 19, 2016
1813290
More consistent checks for URL with authority or path-only.
SimonSapin Feb 19, 2016
aaa1540
Re-export OpaqueOrigin. It is exposed publicly through Origin::Opaque
SimonSapin Feb 19, 2016
c9e687c
Add a scheme setter
SimonSapin Feb 19, 2016
0c30434
Add host setters.
SimonSapin Feb 19, 2016
f8f9176
More setters
SimonSapin Feb 23, 2016
5425385
Add a path setter
SimonSapin Feb 26, 2016
fc9a1db
Username and passowrd setters
SimonSapin Feb 26, 2016
8306485
More WebIDL implementations.
SimonSapin Feb 26, 2016
06f2faf
Port setters
SimonSapin Mar 1, 2016
a1f389f
All setters.
SimonSapin Mar 1, 2016
cb61d43
Replase set_ipv{4,6}_host with set_ip_host taking IpAddr.
SimonSapin Mar 23, 2016
450af0e
Maintain the invariant that an URL can not be both non-relative and s…
SimonSapin Mar 23, 2016
4ee7681
Add Url::into_string
SimonSapin Mar 23, 2016
9bf2c60
Rename non-relative to cannot-be-a-base, per upcoming spec change.
SimonSapin Mar 23, 2016
ca6a4ae
Remove some `unsafe` blocks.
SimonSapin Mar 23, 2016
6830dec
Back to the builder pattern after all.
SimonSapin Mar 24, 2016
b4bbaaa
Docs
SimonSapin Mar 24, 2016
ef0a1b2
Move webidl.rs to Servo.
SimonSapin Mar 25, 2016
d0c2bc2
One unit tests crate.
SimonSapin Mar 30, 2016
8813343
Percent-encoding yields `&str` instead of `char`.
SimonSapin Apr 1, 2016
988494d
Replace {lossy_,}utf8_percent_decode with percent_decode().decode_utf…
SimonSapin Apr 1, 2016
31cdce5
form_urlencoded::parse returns an iterator.
SimonSapin Apr 1, 2016
837a8da
Introduce "output encoding", per spec.
SimonSapin Apr 2, 2016
507ff3f
Self
SimonSapin Apr 2, 2016
8e6418a
Don’t take time to run 0 in-crate unit tests
SimonSapin Apr 2, 2016
d3e9824
Cow wrangling. (Reduce allocations/copying.)
SimonSapin Apr 2, 2016
bea7a48
form_urlencoded::Serializer is a "stateful" object.
SimonSapin Apr 2, 2016
6f716e1
Add Url::mutate_query_pairs
SimonSapin Apr 2, 2016
125cf96
Method chaining
SimonSapin Apr 2, 2016
2375850
Backport to Rust 1.7
SimonSapin Apr 2, 2016
6c6386d
Url::mutate_query_pairs return a value with Drop rather than take a c…
SimonSapin Apr 3, 2016
dd2d1ea
Rename append_pairs to append_pair_iter
SimonSapin Apr 3, 2016
224aee6
Add form_urlencoded::Parse::into_owned
SimonSapin Apr 8, 2016
f4bd6e5
Check invariants during tests.
SimonSapin Apr 4, 2016
0cd4d36
Rename test crates.
SimonSapin Apr 8, 2016
e8df8a3
Prepare for more than one kind of data-driven test.
SimonSapin Apr 8, 2016
8685112
Bring back urlutils.rs / webidl.rs after all
SimonSapin Apr 8, 2016
92eb5a6
Test harness for setters.
SimonSapin Apr 8, 2016
81779d5
Add protocol setter tests.
SimonSapin Apr 12, 2016
eb4d9b1
Username setter tests and fixes.
SimonSapin Apr 12, 2016
777413d
Password setter tests and fixes
SimonSapin Apr 12, 2016
42e608e
host setter tests and fixes
SimonSapin Apr 13, 2016
e65ece7
Add hostname setter tests
SimonSapin Apr 13, 2016
26bdb3a
Port setter tests and fixes
SimonSapin Apr 13, 2016
680d93c
pathname setter tests and fixes
SimonSapin Apr 13, 2016
de99ede
Add search setter tests
SimonSapin Apr 13, 2016
d6da85d
Add tests for hash setter.
SimonSapin Apr 13, 2016
1fdd019
Rename append_pair_iter to extend_pairs
SimonSapin Apr 19, 2016
8bc3285
Typo fix.
SimonSapin Apr 19, 2016
adba760
Copyright date
SimonSapin Apr 19, 2016
cd9fda8
Fix/clarify comments, and add a debug_assert!
SimonSapin Apr 19, 2016
806bab0
form_urlencoded::Parse::into_owned returns a dedicated type
SimonSapin Apr 19, 2016
9602247
Use an atomic counter rather than allocation to make opaque origin un…
SimonSapin Apr 19, 2016
3f92946
Fewer magic numbers.
SimonSapin Apr 20, 2016
e403579
More detailed error type for Url::set_host
SimonSapin Apr 20, 2016
f6996c8
Have a single `impl Url` block with public methods.
SimonSapin Apr 20, 2016
18c0806
1.0.0
SimonSapin Apr 20, 2016
4a59d93
Let’s not try to manually maintain a list of authors.
SimonSapin Apr 20, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/target
/Cargo.lock
target
Cargo.lock
/.cargo/config
48 changes: 15 additions & 33 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]

name = "url"
version = "0.5.9"
authors = [ "Simon Sapin <simon.sapin@exyr.org>" ]
version = "1.0.0"
authors = ["The rust-url developers"]

description = "URL library for Rust, based on the WHATWG URL Standard"
documentation = "http://servo.github.io/rust-url/url/index.html"
Expand All @@ -12,46 +12,28 @@ keywords = ["url", "parser"]
license = "MIT/Apache-2.0"

[[test]]
name = "format"
[[test]]
name = "form_urlencoded"
[[test]]
name = "idna"
[[test]]
name = "punycode"
[[test]]
name = "tests"
name = "unit"

[[test]]
name = "wpt"
name = "data"
harness = false

[lib]
test = false

[dev-dependencies]
rustc-test = "0.1"
rustc-serialize = "0.3"

[features]
query_encoding = ["encoding"]
serde_serialization = ["serde"]
heap_size = ["heapsize", "heapsize_plugin"]

[dependencies.heapsize]
version = ">=0.1.1, <0.4"
optional = true

[dependencies.heapsize_plugin]
version = "0.1.0"
optional = true

[dependencies.encoding]
version = "0.2"
optional = true

[dependencies.serde]
version = ">=0.6.1, <0.8"
optional = true

[dependencies]
uuid = { version = "0.2", features = ["v4"] }
rustc-serialize = "0.3"
unicode-bidi = "0.2.3"
unicode-normalization = "0.1.2"
idna = { version = "0.1.0", path = "./idna" }
heapsize = {version = ">=0.1.1, <0.4", optional = true}
heapsize_plugin = {version = "0.1.0", optional = true}
encoding = {version = "0.2", optional = true}
serde = {version = ">=0.6.1, <0.8", optional = true}
rustc-serialize = {version = "0.3", optional = true}
matches = "0.1"
3 changes: 1 addition & 2 deletions LICENSE-MIT
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Copyright (c) 2006-2009 Graydon Hoare
Copyright (c) 2009-2013 Mozilla Foundation
Copyright (c) 2013-2016 The rust-url developers

Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
test:
cargo test --features query_encoding
cargo test --features serde_serialization
cargo test
cargo test --features "query_encoding serde rustc-serialize"
[ x$$TRAVIS_RUST_VERSION != xnightly ] || cargo test --features heap_size

doc:
Expand Down
24 changes: 24 additions & 0 deletions idna/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "idna"
version = "0.1.0"
authors = ["The rust-url developers"]
description = "IDNA (Internationalizing Domain Names in Applications) and Punycode."
repository = "https://github.com/servo/rust-url/"
license = "MIT/Apache-2.0"

[lib]
doctest = false
test = false

[[test]]
name = "tests"
harness = false

[dev-dependencies]
rustc-test = "0.1"
rustc-serialize = "0.3"

[dependencies]
unicode-bidi = "0.2.3"
unicode-normalization = "0.1.2"
matches = "0.1"
File renamed without changes.
73 changes: 73 additions & 0 deletions idna/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2016 The rust-url developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! This Rust crate implements IDNA
//! [per the WHATWG URL Standard](https://url.spec.whatwg.org/#idna).
//!
//! It also exposes the underlying algorithms from [*Unicode IDNA Compatibility Processing*
//! (Unicode Technical Standard #46)](http://www.unicode.org/reports/tr46/)
//! and [Punycode (RFC 3492)](https://tools.ietf.org/html/rfc3492).
//!
//! Quoting from [UTS #46’s introduction](http://www.unicode.org/reports/tr46/#Introduction):
//!
//! > Initially, domain names were restricted to ASCII characters.
//! > A system was introduced in 2003 for internationalized domain names (IDN).
//! > This system is called Internationalizing Domain Names for Applications,
//! > or IDNA2003 for short.
//! > This mechanism supports IDNs by means of a client software transformation
//! > into a format known as Punycode.
//! > A revision of IDNA was approved in 2010 (IDNA2008).
//! > This revision has a number of incompatibilities with IDNA2003.
//! >
//! > The incompatibilities force implementers of client software,
//! > such as browsers and emailers,
//! > to face difficult choices during the transition period
//! > as registries shift from IDNA2003 to IDNA2008.
//! > This document specifies a mechanism
//! > that minimizes the impact of this transition for client software,
//! > allowing client software to access domains that are valid under either system.

#[macro_use] extern crate matches;
extern crate unicode_bidi;
extern crate unicode_normalization;

pub mod punycode;
pub mod uts46;

/// The [domain to ASCII](https://url.spec.whatwg.org/#concept-domain-to-ascii) algorithm.
///
/// Return the ASCII representation a domain name,
/// normalizing characters (upper-case to lower-case and other kinds of equivalence)
/// and using Punycode as necessary.
///
/// This process may fail.
pub fn domain_to_ascii(domain: &str) -> Result<String, uts46::Errors> {
uts46::to_ascii(domain, uts46::Flags {
use_std3_ascii_rules: false,
transitional_processing: true, // XXX: switch when Firefox does
verify_dns_length: false,
})
}

/// The [domain to Unicode](https://url.spec.whatwg.org/#concept-domain-to-unicode) algorithm.
///
/// Return the Unicode representation of a domain name,
/// normalizing characters (upper-case to lower-case and other kinds of equivalence)
/// and decoding Punycode as necessary.
///
/// This may indicate [syntax violations](https://url.spec.whatwg.org/#syntax-violation)
/// but always returns a string for the mapped domain.
pub fn domain_to_unicode(domain: &str) -> (String, Result<(), uts46::Errors>) {
uts46::to_unicode(domain, uts46::Flags {
use_std3_ascii_rules: false,

// Unused:
transitional_processing: true,
verify_dns_length: false,
})
}
7 changes: 3 additions & 4 deletions make_idna_table.py → idna/src/make_uts46_mapping_table.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
# Copyright 2013-2014 Valentin Gosu.
# Copyright 2013-2014 The rust-url developers.
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.


# Run as: python make_idna_table.py idna_table.txt > src/idna_table.rs
# Run as: python make_uts46_mapping_table.py IdnaMappingTable.txt > uts46_mapping_table.rs
# You can get the latest idna table from
# http://www.unicode.org/Public/idna/latest/IdnaMappingTable.txt

print('''\
// Copyright 2013-2014 Valentin Gosu.
// Copyright 2013-2014 The rust-url developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
Expand Down
17 changes: 8 additions & 9 deletions src/punycode.rs → idna/src/punycode.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 Simon Sapin.
// Copyright 2013 The rust-url developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
Expand Down Expand Up @@ -185,11 +185,11 @@ pub fn encode(input: &[char]) -> Option<String> {
break
}
let value = t + ((q - t) % (BASE - t));
value_to_digit(value, &mut output);
output.push(value_to_digit(value));
q = (q - t) / (BASE - t);
k += BASE;
}
value_to_digit(q, &mut output);
output.push(value_to_digit(q));
bias = adapt(delta, processed + 1, processed == basic_length);
delta = 0;
processed += 1;
Expand All @@ -203,11 +203,10 @@ pub fn encode(input: &[char]) -> Option<String> {


#[inline]
fn value_to_digit(value: u32, output: &mut String) {
let code_point = match value {
0 ... 25 => value + 0x61, // a..z
26 ... 35 => value - 26 + 0x30, // 0..9
fn value_to_digit(value: u32) -> char {
match value {
0 ... 25 => (value as u8 + 'a' as u8) as char, // a..z
26 ... 35 => (value as u8 - 26 + '0' as u8) as char, // 0..9
_ => panic!()
};
unsafe { output.as_mut_vec().push(code_point as u8) }
}
}
Loading