|
|
@@ -22,6 +22,12 @@ use percent_encoding::{
|
|
|
PATH_SEGMENT_ENCODE_SET
|
|
|
};
|
|
|
|
|
|
+define_encode_set! {
|
|
|
+ // The backslash (\) character is treated as a path separator in special URLs
|
|
|
+ // so it needs to be additionally escaped in that case.
|
|
|
+ pub SPECIAL_PATH_SEGMENT_ENCODE_SET = [PATH_SEGMENT_ENCODE_SET] | {'\\'}
|
|
|
+}
|
|
|
+
|
|
|
pub type ParseResult<T> = Result<T, ParseError>;
|
|
|
|
|
|
macro_rules! simple_enum_error {
|
|
|
@@ -1011,8 +1017,13 @@ impl<'a> Parser<'a> {
|
|
|
_ => {
|
|
|
self.check_url_code_point(c, &input);
|
|
|
if self.context == Context::PathSegmentSetter {
|
|
|
- self.serialization.extend(utf8_percent_encode(
|
|
|
- utf8_c, PATH_SEGMENT_ENCODE_SET));
|
|
|
+ if scheme_type.is_special() {
|
|
|
+ self.serialization.extend(utf8_percent_encode(
|
|
|
+ utf8_c, SPECIAL_PATH_SEGMENT_ENCODE_SET));
|
|
|
+ } else {
|
|
|
+ self.serialization.extend(utf8_percent_encode(
|
|
|
+ utf8_c, PATH_SEGMENT_ENCODE_SET));
|
|
|
+ }
|
|
|
} else {
|
|
|
self.serialization.extend(utf8_percent_encode(
|
|
|
utf8_c, DEFAULT_ENCODE_SET));
|