From 7cf28a9b5f57ccee3bb4a00805c47d62b75f0479 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Tue, 11 Jul 2023 11:56:32 -0600 Subject: [PATCH] De-duplicate url parser percent encoding constants with those defined in percent_encoding. --- url/src/lib.rs | 4 ++-- url/src/parser.rs | 23 +++-------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/url/src/lib.rs b/url/src/lib.rs index ad3c89001..479a15757 100644 --- a/url/src/lib.rs +++ b/url/src/lib.rs @@ -134,8 +134,8 @@ pub use form_urlencoded; extern crate serde; use crate::host::HostInternal; -use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO}; -use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode}; +use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT}; +use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode, USERINFO}; use std::borrow::Borrow; use std::cmp; use std::fmt::{self, Write}; diff --git a/url/src/parser.rs b/url/src/parser.rs index 765cc027c..3d6aa247e 100644 --- a/url/src/parser.rs +++ b/url/src/parser.rs @@ -13,26 +13,9 @@ use std::str; use crate::host::{Host, HostInternal}; use crate::Url; use form_urlencoded::EncodingOverride; -use percent_encoding::{percent_encode, utf8_percent_encode, AsciiSet, CONTROLS}; - -/// https://url.spec.whatwg.org/#fragment-percent-encode-set -const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); - -/// https://url.spec.whatwg.org/#path-percent-encode-set -const PATH: &AsciiSet = &FRAGMENT.add(b'#').add(b'?').add(b'{').add(b'}'); - -/// https://url.spec.whatwg.org/#userinfo-percent-encode-set -pub(crate) const USERINFO: &AsciiSet = &PATH - .add(b'/') - .add(b':') - .add(b';') - .add(b'=') - .add(b'@') - .add(b'[') - .add(b'\\') - .add(b']') - .add(b'^') - .add(b'|'); +use percent_encoding::{ + percent_encode, utf8_percent_encode, AsciiSet, CONTROLS, FRAGMENT, PATH, USERINFO, +}; pub(crate) const PATH_SEGMENT: &AsciiSet = &PATH.add(b'/').add(b'%');