Skip to content

Commit b77a81b

Browse files
authored
Use SPECIAL_PATH_SEGMENT when encoding path in from_file_path (#902)
* Use SPECIAL_PATH_SEGMENT when encoding path in from_file_path Fixes #901 * cargo fmt
1 parent f447500 commit b77a81b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

url/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ pub use form_urlencoded;
146146
extern crate serde;
147147

148148
use crate::host::HostInternal;
149-
use crate::parser::{to_u32, Context, Parser, SchemeType, PATH_SEGMENT, USERINFO};
149+
use crate::parser::{
150+
to_u32, Context, Parser, SchemeType, PATH_SEGMENT, SPECIAL_PATH_SEGMENT, USERINFO,
151+
};
150152
use percent_encoding::{percent_decode, percent_encode, utf8_percent_encode};
151153
use std::borrow::Borrow;
152154
use std::cmp;
@@ -2817,7 +2819,7 @@ fn path_to_file_url_segments(
28172819
serialization.push('/');
28182820
serialization.extend(percent_encode(
28192821
component.as_os_str().as_bytes(),
2820-
PATH_SEGMENT,
2822+
SPECIAL_PATH_SEGMENT,
28212823
));
28222824
}
28232825
if empty {

url/tests/unit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fn new_file_paths() {
146146
assert_from_file_path!("/foo/bar");
147147
assert_from_file_path!("/foo/ba\0r", "/foo/ba%00r");
148148
assert_from_file_path!("/foo/ba%00r", "/foo/ba%2500r");
149+
assert_from_file_path!("/foo/ba\\r", "/foo/ba%5Cr");
149150
}
150151
}
151152

0 commit comments

Comments
 (0)