Migrate from urlencoding to percent-encoding (#11144)

## Summary

This lets us drop a dependency entirely. `percent-encoding` is used by
`url` and so is already in the graph, whereas `urlencoding` isn't used
by anything else.
This commit is contained in:
Charlie Marsh 2025-01-31 16:29:46 -05:00 committed by GitHub
parent 027db656aa
commit 8adf4a8977
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 30 additions and 32 deletions

View file

@ -38,6 +38,7 @@ html-escape = { workspace = true }
http = { workspace = true }
itertools = { workspace = true }
jiff = { workspace = true }
percent-encoding = { workspace = true }
reqwest = { workspace = true }
reqwest-middleware = { workspace = true }
reqwest-retry = { workspace = true }
@ -52,7 +53,6 @@ tokio = { workspace = true }
tokio-util = { workspace = true }
tracing = { workspace = true }
url = { workspace = true }
urlencoding = { workspace = true }
[dev-dependencies]
anyhow = { workspace = true }

View file

@ -93,7 +93,7 @@ impl SimpleHtml {
// Extract the hash, which should be in the fragment.
let decoded = html_escape::decode_html_entities(href);
let (path, hashes) = if let Some((path, fragment)) = decoded.split_once('#') {
let fragment = urlencoding::decode(fragment)?;
let fragment = percent_encoding::percent_decode_str(fragment).decode_utf8()?;
(
path,
if fragment.trim().is_empty() {
@ -131,7 +131,8 @@ impl SimpleHtml {
let filename = filename.split('?').next().unwrap_or(filename);
// Unquote the filename.
let filename = urlencoding::decode(filename)
let filename = percent_encoding::percent_decode_str(filename)
.decode_utf8()
.map_err(|_| Error::UnsupportedFilename(filename.to_string()))?;
// Extract the `requires-python` value, which should be set on the