misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux
Rust bittorrent-clientdebriddownload-acceleratordownload-managerdownloadmanagereguifile-downloadergallery-dlidmidm-alternativeinternet-download-managerm3u8-downloadermagnetplaylist-downloaderreal-debridrusttorrent-clientvideo-downloaderyoutube-downloaderyt-dlp
Browser link import: tighter handling of site data (#415)
Ahmed Nefzaouieca00e456bd5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 766c0fa1..b206b777 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see### Fixed+- Browser link import: tighter handling of site data.- Crash reports: a freeze that was over before its snapshot was taken says so, instead of calling it a deadlock in code that was only waiting for events ([#355](https://github.com/anefzaoui/misterdownloadmanager/issues/355)).- **Move/Rename** was greyed out with several downloads selected, for example a set just added to a queue. It now asks for a folder and moves them all there ([#333](https://github.com/anefzaoui/misterdownloadmanager/issues/333)).- The extension no longer asks you to update MDM when only a bug-fix version separates them, which it did even when there was no update to get.diff --git a/ROADMAP.md b/ROADMAP.mdindex a7915560..018e6859 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -134,6 +134,7 @@ Everything below ships together, in version 0.5.0.- ✅ Far more file types taken by default: AI models and datasets, 3D and CAD, design and cameraRAW, ebooks, Office, disk images and split archives; a list never edited gains them([#382](https://github.com/anefzaoui/misterdownloadmanager/issues/382))+- ✅ Browser link import: tighter handling of site data- ✅ The extension asks for a newer MDM only when a whole release separates them, not over abug-fix version- ✅ Add URL: a YouTube playlist opens the video window; Dailymotion's embedded player is lookeddiff --git a/crates/app/src/app.rs b/crates/app/src/app.rsindex 959c7889..a70b892a 100644--- a/crates/app/src/app.rs+++ b/crates/app/src/app.rs@@ -667,6 +667,20 @@ fn sent_referrer(url: &url::Url, referrer: &str) -> Option<String> {Some(format!("{}/", from.origin().ascii_serialization()))}+/// What a link found on a page takes along from that page.+fn page_data_for(link: &str, page: Option<&str>, data: Option<&str>) -> Option<String> {+ let (link, page) = (url::Url::parse(link).ok()?, url::Url::parse(page?).ok()?);+ let same_host = link.host_str().is_some()+ && link+ .host_str()+ .map(str::to_ascii_lowercase)+ .eq(&page.host_str().map(str::to_ascii_lowercase));+ let downgrade = page.scheme() == "https" && link.scheme() != "https";+ (same_host && !downgrade)+ .then(|| data.map(str::to_owned))+ .flatten()+}+/// Marks each file the engine starts writing as downloaded from the web (Mark-of-the-Web, macOS'/// quarantine: win32 / unix `mark_downloaded`), as browsers mark theirs. Only http(s) addresses/// (an FTP address may carry its login).@@ -2149,7 +2163,7 @@ impl App {.map(|url| crate::transfer::Imported {url: url.clone(),referer: cmd.referer.clone(),- cookies: cmd.cookies.clone(),+ cookies: page_data_for(url, cmd.referer.as_deref(), cmd.cookies.as_deref()),user_agent: cmd.user_agent.clone(),private: cmd.private,})@@ -8755,3 +8769,33 @@ mod trim_tests {assert_eq!(times, [2, 120, 720, 1320]);}}++#[cfg(test)]+mod page_data_tests {+ use super::page_data_for;++ const PAGE: Option<&str> = Some("https://forum.example/thread/1");+ const DATA: Option<&str> = Some("a=1");++ #[test]+ fn links_take_what_belongs_to_them() {+ let got = |link| page_data_for(link, PAGE, DATA);+ assert_eq!(got("https://forum.example/files/a.zip").as_deref(), DATA);+ assert_eq!(got("https://FORUM.example/b.zip").as_deref(), DATA);+ assert_eq!(got("https://other.test/a.zip"), None);+ assert_eq!(got("https://forum.example.other.test/a.zip"), None);+ assert_eq!(got("https://cdn.forum.example/a.zip"), None);+ assert_eq!(got("http://forum.example/a.zip"), None);+ assert_eq!(got("not an address"), None);+ }++ #[test]+ fn no_page_or_nothing_to_take() {+ assert_eq!(page_data_for("https://a.test/x", None, DATA), None);+ assert_eq!(+ page_data_for("https://a.test/x", Some("https://a.test/"), None),+ None+ );+ assert_eq!(page_data_for("https://a.test/x", Some("nope"), DATA), None);+ }+}