Преглед изворни кода

fix: Get Profile Filename (#54)

Pylogmon пре 1 година
родитељ
комит
4f35d907cb
3 измењених фајлова са 13 додато и 1 уклоњено
  1. 1 0
      src-tauri/Cargo.lock
  2. 1 0
      src-tauri/Cargo.toml
  3. 11 1
      src-tauri/src/config/prfitem.rs

+ 1 - 0
src-tauri/Cargo.lock

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

+ 1 - 0
src-tauri/Cargo.toml

@@ -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]

+ 11 - 1
src-tauri/src/config/prfitem.rs

@@ -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,
         };