Skip to content

Commit

Permalink
Update to percent-encoding 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Aug 17, 2019
1 parent 9392180 commit 734fa6d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/net/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mime_guess = "2.0.0-alpha.6"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
openssl = "0.10"
percent-encoding = "1.0"
percent-encoding = "2.0"
pixels = {path = "../pixels"}
profile_traits = {path = "../profile_traits"}
rayon = "1"
Expand Down
2 changes: 1 addition & 1 deletion components/net_traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ malloc_size_of_derive = "0.1"
mime = "0.3"
msg = {path = "../msg"}
num-traits = "0.2"
percent-encoding = "1.0"
percent-encoding = "2.0"
pixels = {path = "../pixels"}
serde = "1.0"
servo_arc = {path = "../servo_arc"}
Expand Down
31 changes: 23 additions & 8 deletions components/net_traits/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,29 @@ pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] {
}

pub fn http_percent_encode(bytes: &[u8]) -> String {
percent_encoding::define_encode_set! {
// This encode set is used for HTTP header values and is defined at
// https://tools.ietf.org/html/rfc5987#section-3.2
pub HTTP_VALUE = [percent_encoding::SIMPLE_ENCODE_SET] | {
' ', '"', '%', '\'', '(', ')', '*', ',', '/', ':', ';', '<', '-', '>', '?',
'[', '\\', ']', '{', '}'
}
}
// This encode set is used for HTTP header values and is defined at
// https://tools.ietf.org/html/rfc5987#section-3.2
const HTTP_VALUE: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
.add(b' ')
.add(b'"')
.add(b'%')
.add(b'\'')
.add(b'(')
.add(b')')
.add(b'*')
.add(b',')
.add(b'/')
.add(b':')
.add(b';')
.add(b'<')
.add(b'-')
.add(b'>')
.add(b'?')
.add(b'[')
.add(b'\\')
.add(b']')
.add(b'{')
.add(b'}');

percent_encoding::percent_encode(bytes, HTTP_VALUE).to_string()
}
2 changes: 1 addition & 1 deletion components/script/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
num-traits = "0.2"
parking_lot = "0.8"
percent-encoding = "1.0"
percent-encoding = "2.0"
phf = "0.7"
pixels = {path = "../pixels"}
profile_traits = {path = "../profile_traits"}
Expand Down

0 comments on commit 734fa6d

Please sign in to comment.