fix: Get Profile Filename (#54)

This commit is contained in:
Pylogmon 2023-12-04 12:15:01 +08:00 committed by GitHub
parent 0bc22db296
commit b7e9d61c72
3 changed files with 13 additions and 1 deletions

1
src-tauri/Cargo.lock generated
View File

@ -575,6 +575,7 @@ dependencies = [
"once_cell",
"open 5.0.1",
"parking_lot",
"percent-encoding",
"port_scanner",
"reqwest",
"rquickjs",

View File

@ -40,6 +40,7 @@ reqwest = { version = "0.11", features = ["json", "rustls-tls"] }
tauri = { version = "1.5", features = ["clipboard-all", "global-shortcut-all", "process-all", "shell-all", "system-tray", "updater", "window-all"] }
window-vibrancy = { version = "0.4.3" }
window-shadows = { version = "0.2" }
percent-encoding = "2.3.1"
[target.'cfg(windows)'.dependencies]

View File

@ -263,7 +263,17 @@ impl PrfItem {
let filename = match header.get("Content-Disposition") {
Some(value) => {
let filename = value.to_str().unwrap_or("");
help::parse_str::<String>(filename, "filename=")
match help::parse_str::<String>(filename, "filename=") {
Some(filename) => Some(filename),
None => match help::parse_str::<String>(filename, "filename*=") {
Some(filename) => {
let iter = percent_encoding::percent_decode(filename.as_bytes());
let filename = iter.decode_utf8().unwrap_or_default();
filename.split("''").last().map(|s| s.to_string())
}
None => None,
},
}
}
None => None,
};