Skip to content

Commit d2a0ab4

Browse files
removed decoder dependency
1 parent 20fbe0c commit d2a0ab4

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Cargo.lock

-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ reqwest = { version = "0.12.5", default-features = false, features = [
1616
"http2",
1717
"socks",
1818
] }
19-
urlencoding = "2.1.3"
2019
tokio = { version = "1.43.1", features = [
2120
"rt-multi-thread",
2221
"macros",

src/engines/yahoo.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,27 @@ fn parse_yahoo_redirect_url(raw_url: &str) -> String {
6969

7070
let encoded_url = &encoded_start[..end_idx];
7171

72-
match urlencoding::decode(encoded_url) {
73-
Ok(decoded) => decoded.into_owned(),
72+
// Manual URL decode using url::form_urlencoded
73+
match percent_decode(encoded_url.as_bytes()) {
74+
Ok(decoded) => decoded,
7475
Err(_) => raw_url.to_string(), // fallback
7576
}
7677
} else {
7778
raw_url.to_string()
7879
}
7980
}
8081

82+
/// Perform a percent-decoding manually using basic Rust stdlib
83+
fn percent_decode(input: &[u8]) -> Result<String, std::string::FromUtf8Error> {
84+
use std::borrow::Cow;
85+
let decoded = url::percent_encoding::percent_decode(input).decode_utf8_lossy();
86+
match decoded {
87+
Cow::Borrowed(s) => Ok(s.to_string()),
88+
Cow::Owned(s) => Ok(s),
89+
}
90+
}
91+
92+
8193
#[async_trait::async_trait]
8294
impl SearchEngine for Yahoo {
8395
async fn results(

0 commit comments

Comments
 (0)