Repository: Y2Z/monolith
Pull request #457 (2025-03-29 21:10:14)

Update 3rd-party deps


Patch:
diff --git a/Cargo.lock b/Cargo.lock
index 89c7d11..c54d608 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -519,9 +519,9 @@ dependencies = [
 
 [[package]]
 name = "cssparser"
-version = "0.34.0"
+version = "0.35.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b7c66d1cd8ed61bf80b38432613a7a2f09401ab8d0501110655f8b341484a3e3"
+checksum = "4e901edd733a1472f944a45116df3f846f54d37e67e68640ac8bb69689aca2aa"
 dependencies = [
  "cssparser-macros",
  "dtoa-short",
@@ -1711,9 +1711,9 @@ dependencies = [
 
 [[package]]
 name = "once_cell"
-version = "1.21.2"
+version = "1.21.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c2806eaa3524762875e21c3dcd057bc4b7bfa01ce4da8d46be1cd43649e1cc6b"
+checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
 
 [[package]]
 name = "openssl"
diff --git a/Cargo.toml b/Cargo.toml
index edcf6ca..f9bc9c5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,8 +26,8 @@ license = "CC0-1.0"
 atty = "0.2.14"  # Used for highlighting network errors
 base64 = "0.22.1"  # Used for integrity attributes
 chrono = "0.4.40"  # Used for formatting timestamps
-clap = { version = "4.5.32", features = ["derive"], optional = true }  # Used for processing CLI arguments
-cssparser = "0.34.0"  # Used for dealing with CSS
+clap = { version = "4.5.34", features = ["derive"], optional = true }  # Used for processing CLI arguments
+cssparser = "0.35.0"  # Used for dealing with CSS
 druid = { version = "0.8.3", optional = true }  # Used for GUI
 encoding_rs = "0.8.35"  # Used for parsing and converting document charsets
 html5ever = "0.28.0"  # Used for all things DOM
@@ -35,7 +35,7 @@ markup5ever_rcdom = "=0.4.0-unofficial"  # Used for manipulating DOM
 percent-encoding = "2.3.1"  # Used for encoding URLs
 sha2 = "0.10.8"  # Used for calculating checksums during integrity checks
 redb = "2.4.0"  # Used for on-disk caching of remote assets
-tempfile = { version = "3.19.0", optional = true }  # Used for on-disk caching of remote assets
+tempfile = { version = "3.19.1", optional = true }  # Used for on-disk caching of remote assets
 url = "2.5.4"  # Used for parsing URLs
 openssl = "0.10.71"  # Used for static linking of the OpenSSL library
 
@@ -47,7 +47,7 @@ features = ["std", "perf-dfa", "unicode-perl"]
 
 # Used for making network requests
 [dependencies.reqwest]
-version = "0.12.14"
+version = "0.12.15"
 default-features = false
 features = ["default-tls", "blocking", "gzip", "brotli", "deflate"]
 
diff --git a/src/html.rs b/src/html.rs
index dd1df93..8b5283c 100644
--- a/src/html.rs
+++ b/src/html.rs
@@ -22,6 +22,9 @@ use crate::url::{
     clean_url, create_data_url, is_url_and_has_protocol, resolve_url, EMPTY_IMAGE_DATA_URL,
 };
 
+const FAVICON_VALUES: &[&str] = &["icon", "shortcut icon"];
+const WHITESPACES: &[char] = &[' ', '\t', '\n', '\x0c', '\r']; // ASCII whitespaces
+
 #[derive(PartialEq, Eq)]
 pub enum LinkType {
     Alternate,
@@ -32,14 +35,11 @@ pub enum LinkType {
     Stylesheet,
 }
 
-struct SrcSetItem<'a> {
-    path: &'a str,
-    descriptor: &'a str, // Width or pixel density descriptor
+pub struct SrcSetItem<'a> {
+    pub path: &'a str,
+    pub descriptor: &'a str, // Width or pixel density descriptor
 }
 
-const FAVICON_VALUES: &[&str] = &["icon", "shortcut icon"];
-const WHITESPACES: &[char] = &[' ', '\t', '\n', '\x0c', '\r']; // ASCII whitespaces
-
 pub fn add_favicon(document: &Handle, favicon_data_url: String) -> RcDom {
     let mut buf: Vec<u8> = Vec::new();
     serialize(
@@ -394,6 +394,8 @@ pub fn parse_srcset(srcset: &str) -> Vec<SrcSetItem> {
     while i < partials.len() {
         let partial = partials[i];
 
+        i += 1;
+
         // Skip empty strings
         if partial.is_empty() {
             continue;
@@ -435,8 +437,6 @@ pub fn parse_srcset(srcset: &str) -> Vec<SrcSetItem> {
             path = None;
             descriptor = None;
         }
-
-        i += 1;
     }
 
     // Final attempt to process what was found


Test patch:
diff --git a/tests/html/mod.rs b/tests/html/mod.rs
index 8aebfed..a1e8e76 100644
--- a/tests/html/mod.rs
+++ b/tests/html/mod.rs
@@ -10,6 +10,7 @@ mod get_node_name;
 mod has_favicon;
 mod is_favicon;
 mod parse_link_type;
+mod parse_srcset;
 mod serialize_document;
 mod set_node_attr;
 mod walk_and_embed_assets;
diff --git a/tests/html/parse_srcset.rs b/tests/html/parse_srcset.rs
new file mode 100644
index 0000000..6fee5f1
--- /dev/null
+++ b/tests/html/parse_srcset.rs
@@ -0,0 +1,27 @@
+//  ██████╗  █████╗ ███████╗███████╗██╗███╗   ██╗ ██████╗
+//  ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗  ██║██╔════╝
+//  ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║  ███╗
+//  ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║   ██║
+//  ██║     ██║  ██║███████║███████║██║██║ ╚████║╚██████╔╝
+//  ╚═╝     ╚═╝  ╚═╝╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝ ╚═════╝
+
+#[cfg(test)]
+mod passing {
+    use monolith::html::{parse_srcset, SrcSetItem};
+
+    #[test]
+    fn three_items_with_width_descriptors_and_newlines() {
+        let srcset = r#"https://some-site.com/width/600/https://media2.some-site.com/2021/07/some-image-073362.jpg 600w,
+                        https://some-site.com/width/960/https://media2.some-site.com/2021/07/some-image-073362.jpg 960w,
+                        https://some-site.com/width/1200/https://media2.some-site.com/2021/07/some-image-073362.jpg 1200w"#;
+        let srcset_items: Vec<SrcSetItem> = parse_srcset(srcset);
+
+        assert_eq!(srcset_items.len(), 3);
+        assert_eq!(srcset_items[0].path, "https://some-site.com/width/600/https://media2.some-site.com/2021/07/some-image-073362.jpg");
+        assert_eq!(srcset_items[0].descriptor, "600w");
+        assert_eq!(srcset_items[1].path, "https://some-site.com/width/960/https://media2.some-site.com/2021/07/some-image-073362.jpg");
+        assert_eq!(srcset_items[1].descriptor, "960w");
+        assert_eq!(srcset_items[2].path, "https://some-site.com/width/1200/https://media2.some-site.com/2021/07/some-image-073362.jpg");
+        assert_eq!(srcset_items[2].descriptor, "1200w");
+    }
+}