diff --git a/url/src/lib.rs b/url/src/lib.rs index d498ee365..78980e85f 100644 --- a/url/src/lib.rs +++ b/url/src/lib.rs @@ -146,7 +146,9 @@ pub use form_urlencoded; extern crate serde; use crate::host::HostInternal; -use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO}; +use crate::parser::{ + to_u32, Context, Parser, SchemeType, PATH_SEGMENT, SPECIAL_PATH_SEGMENT, USERINFO, +}; use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode}; use std::borrow::Borrow; use std::cmp; @@ -2817,7 +2819,7 @@ fn path_to_file_url_segments( serialization.push('/'); serialization.extend(percent_encode( component.as_os_str().as_bytes(), - PATH_SEGMENT, + SPECIAL_PATH_SEGMENT, )); } if empty { diff --git a/url/tests/unit.rs b/url/tests/unit.rs index c27f237ba..f8069dc89 100644 --- a/url/tests/unit.rs +++ b/url/tests/unit.rs @@ -146,6 +146,7 @@ fn new_file_paths() { assert_from_file_path!("/foo/bar"); assert_from_file_path!("/foo/ba\0r", "/foo/ba%00r"); assert_from_file_path!("/foo/ba%00r", "/foo/ba%2500r"); + assert_from_file_path!("/foo/ba\\r", "/foo/ba%5Cr"); } }