Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Enable HTTP decompression and fix icon discovery

Neeraj Gupta4145d941fc87
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 2fa6c9e2c2..e6dd98da36 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -412,6 +412,18 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "async-compression"
+version = "0.4.50"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee19bd99b43e3691acbad4e840420a4881cea6c0b66a208125a824f8fd53f5a1"
+dependencies = [
+ "compression-codecs",
+ "compression-core",
+ "pin-project-lite",
+ "tokio",
+]
+
[[package]]
name = "async-executor"
version = "1.13.3"
@@ -1448,6 +1460,24 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "compression-codecs"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "98fc98460ba0ad5317075d3632b8dfc45d0be8c4a49347c2a38272019717614a"
+dependencies = [
+ "brotli 9.0.0",
+ "compression-core",
+ "flate2",
+ "memchr",
+]
+
+[[package]]
+name = "compression-core"
+version = "0.4.33"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6e8ccc4ea9f6acc32d102c0f6d471d11d913ad15f20c04de743374861fa1d414"
+
[[package]]
name = "concurrent-queue"
version = "2.5.0"
@@ -10283,12 +10313,17 @@ version = "0.6.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51"
dependencies = [
+ "async-compression",
"bitflags 2.11.0",
"bytes",
+ "futures-core",
"futures-util",
"http",
"http-body",
+ "http-body-util",
"pin-project-lite",
+ "tokio",
+ "tokio-util",
"tower",
"tower-layer",
"tower-service",
diff --git a/rust/crates/core/Cargo.toml b/rust/crates/core/Cargo.toml
index d9fb9e0951..051a60a698 100644
--- a/rust/crates/core/Cargo.toml
+++ b/rust/crates/core/Cargo.toml
@@ -25,7 +25,7 @@ zeroize.workspace = true
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
bytes = "1.12.1"
futures-core = "0.3.34"
-reqwest = { workspace = true, features = ["stream"] }
+reqwest = { workspace = true, features = ["stream", "gzip", "brotli"] }
tokio = { workspace = true, features = ["time"] }
[target.'cfg(target_arch = "wasm32")'.dependencies]
diff --git a/rust/crates/icons/src/discovery.rs b/rust/crates/icons/src/discovery.rs
index 7e85fb2ab0..beb92e22b1 100644
--- a/rust/crates/icons/src/discovery.rs
+++ b/rust/crates/icons/src/discovery.rs
@@ -41,9 +41,6 @@ pub(crate) fn icon_urls(html: &str, page: &Url) -> Vec<Url> {
if !icon && !touch {
continue;
}
- let svg = element
- .attr("type")
- .is_some_and(|kind| kind.trim().eq_ignore_ascii_case("image/svg+xml"));
let Some(href) = element
.attr("href")
.map(str::trim)
@@ -58,6 +55,13 @@ pub(crate) fn icon_urls(html: &str, page: &Url) -> Vec<Url> {
continue;
}
url.set_fragment(None);
+ let svg = element
+ .attr("type")
+ .is_some_and(|kind| kind.trim().eq_ignore_ascii_case("image/svg+xml"))
+ || url
+ .path()
+ .rsplit_once('.')
+ .is_some_and(|(_, extension)| extension.eq_ignore_ascii_case("svg"));
let rank = (svg, size_rank(element.attr("sizes").unwrap_or("")), !icon);
candidates.push((rank, url));
}
diff --git a/rust/crates/icons/src/format.rs b/rust/crates/icons/src/format.rs
index 19d8546ad8..c71da4dbd0 100644
--- a/rust/crates/icons/src/format.rs
+++ b/rust/crates/icons/src/format.rs
@@ -42,7 +42,7 @@ fn validate_ico(data: &[u8]) -> Option<()> {
let count = usize::from(u16::from_le_bytes([count[0], count[1]]));
let directory = data.get(6..6 + count * 16)?;
let mut budget = MAX_BYTES;
- for entry in directory.chunks_exact(16) {
+ for entry in directory.as_chunks::<16>().0 {
let length = u32::from_le_bytes([entry[8], entry[9], entry[10], entry[11]]) as usize;
if length < 8 {
return None;