Skip to content

Commit d77dfb4

Browse files
authored
Revert "Normalize URL paths: convert /.//p, /..//p, and //p to p (#943)" (#999)
* Revert "Normalize URL paths: convert /.//p, /..//p, and //p to p (#943)" This reverts commit b08a655. * Update rust version to 1.63 - required by libc v0.2.164 * Update github workflow runner to rust 1.63
1 parent da64903 commit d77dfb4

File tree

4 files changed

+10
-58
lines changed

4 files changed

+10
-58
lines changed

.github/workflows/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: [ubuntu-latest, macos-latest, windows-latest]
18-
rust: [1.57.0, 1.67.0, stable, beta, nightly]
18+
rust: [1.63.0, 1.67.0, stable, beta, nightly]
1919
exclude:
2020
- os: macos-latest
2121
rust: 1.67.0
@@ -37,9 +37,9 @@ jobs:
3737
toolchain: ${{ matrix.rust }}
3838
# Add toolchain for no_std tests
3939
- run: rustup toolchain install nightly
40-
- name: Downgrade idna_adapter on Rust 1.57.0
40+
- name: Downgrade idna_adapter on Rust 1.63.0
4141
if: |
42-
matrix.rust == '1.57.0'
42+
matrix.rust == '1.63.0'
4343
run: cargo update -p idna_adapter --precise 1.1.0
4444
- name: Add `aarch64-unknown-none` toolchain for `no_std` tests
4545
if: |
@@ -58,7 +58,7 @@ jobs:
5858
- name: Run debugger_visualizer tests
5959
if: |
6060
matrix.os == 'windows-latest' &&
61-
matrix.rust != '1.57.0' &&
61+
matrix.rust != '1.63.0' &&
6262
matrix.rust != '1.67.0'
6363
run: cargo test --test debugger_visualizer --features "url/debugger_visualizer,url_debug_tests/debugger_visualizer" -- --test-threads=1 || echo "debugger test failed"
6464
continue-on-error: true # Fails on GH actions, but not locally.

url/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ categories = ["parser-implementations", "web-programming", "encoding", "no-std"]
1414
license = "MIT OR Apache-2.0"
1515
include = ["src/**/*", "LICENSE-*", "README.md", "tests/**"]
1616
edition = "2018"
17-
rust-version = "1.57" # From idna
17+
rust-version = "1.63" # From libc
1818

1919
[dev-dependencies]
2020
serde = { version = "1.0", features = ["derive"] }

url/src/lib.rs

+1-53
Original file line numberDiff line numberDiff line change
@@ -1757,39 +1757,6 @@ impl Url {
17571757
let old_after_path_pos = to_u32(self.serialization.len()).unwrap();
17581758
let cannot_be_a_base = self.cannot_be_a_base();
17591759
let scheme_type = SchemeType::from(self.scheme());
1760-
let mut path_empty = false;
1761-
1762-
// Check ':' and then see if the next character is '/'
1763-
let mut has_host = if let Some(index) = self.serialization.find(":") {
1764-
if self.serialization.len() > index + 1
1765-
&& self.serialization.as_bytes().get(index + 1) == Some(&b'/')
1766-
{
1767-
let rest = &self.serialization[(index + ":/".len())..];
1768-
let host_part = rest.split('/').next().unwrap_or("");
1769-
path_empty = rest.is_empty();
1770-
!host_part.is_empty() && !host_part.contains('@')
1771-
} else {
1772-
false
1773-
}
1774-
} else {
1775-
false
1776-
};
1777-
1778-
// Ensure the path length is greater than 1 to account
1779-
// for cases where "/." is already appended from serialization
1780-
// If we set path, then we already checked the other two conditions:
1781-
// https://url.spec.whatwg.org/#url-serializing
1782-
// 1. The host is null
1783-
// 2. the first segment of the URL's path is an empty string
1784-
if path.len() > 1 {
1785-
if let Some(index) = self.serialization.find(":") {
1786-
let removal_start = index + ":".len();
1787-
if self.serialization[removal_start..].starts_with("/.") {
1788-
self.path_start -= "/.".len() as u32;
1789-
}
1790-
}
1791-
}
1792-
17931760
self.serialization.truncate(self.path_start as usize);
17941761
self.mutate(|parser| {
17951762
if cannot_be_a_base {
@@ -1799,33 +1766,14 @@ impl Url {
17991766
}
18001767
parser.parse_cannot_be_a_base_path(parser::Input::new_no_trim(path));
18011768
} else {
1769+
let mut has_host = true; // FIXME
18021770
parser.parse_path_start(
18031771
scheme_type,
18041772
&mut has_host,
18051773
parser::Input::new_no_trim(path),
18061774
);
18071775
}
18081776
});
1809-
1810-
// For cases where normalization is applied across both the serialization and the path.
1811-
// Append "/." immediately after the scheme (up to ":")
1812-
// This is done if three conditions are met.
1813-
// https://url.spec.whatwg.org/#url-serializing
1814-
// 1. The host is null
1815-
// 2. The url's path length is greater than 1
1816-
// 3. the first segment of the URL's path is an empty string
1817-
if !has_host && path.len() > 1 && path_empty {
1818-
if let Some(index) = self.serialization.find(":") {
1819-
if self.serialization.len() > index + 2
1820-
&& self.serialization.as_bytes().get(index + 1) == Some(&b'/')
1821-
&& self.serialization.as_bytes().get(index + 2) == Some(&b'/')
1822-
{
1823-
self.serialization.insert_str(index + ":".len(), "/.");
1824-
self.path_start += "/.".len() as u32;
1825-
}
1826-
}
1827-
}
1828-
18291777
self.restore_after_path(old_after_path_pos, &after_path);
18301778
}
18311779

url/tests/expected_failures.txt

+4
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@
4343
<file://monkey/> set pathname to <\\\\>
4444
<file:///unicorn> set pathname to <//\\/>
4545
<file:///unicorn> set pathname to <//monkey/..//>
46+
<non-spec:/> set pathname to </.//p>
47+
<non-spec:/> set pathname to </..//p>
48+
<non-spec:/> set pathname to <//p>
49+
<non-spec:/.//> set pathname to <p>

0 commit comments

Comments
 (0)