Tabs: accept embedded favicons up to 64 KiB (a theme's replacement logo was dropped)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b13d9acf14
commit
b55b66c4ca
1 changed files with 11 additions and 1 deletions
|
|
@ -61,7 +61,10 @@ impl TabState {
|
|||
id,
|
||||
url,
|
||||
title: clip(title, 512),
|
||||
favicon: clip(favicon, 2048).filter(|href| href.starts_with("https://") || href.starts_with("data:image/")),
|
||||
// An embedded icon (a site's own, or a theme's replacement logo) is bigger than any URL.
|
||||
favicon: favicon.filter(|href| {
|
||||
(href.starts_with("https://") && href.len() <= 2048) || (href.starts_with("data:image/") && href.len() <= 64 * 1024)
|
||||
}),
|
||||
focused,
|
||||
loading: None,
|
||||
}
|
||||
|
|
@ -209,6 +212,13 @@ mod tests {
|
|||
assert_eq!((state.title, state.favicon, state.focused), (None, None, Some(true)));
|
||||
let state = TabState::reported("a".into(), None, Some("Home".into()), Some("data:image/png;base64,AA".into()), None);
|
||||
assert_eq!(state.favicon.as_deref(), Some("data:image/png;base64,AA"));
|
||||
let big = format!("data:image/png;base64,{}", "A".repeat(30_000));
|
||||
let state = TabState::reported("tab-1".into(), None, None, Some(big.clone()), None);
|
||||
assert_eq!(state.favicon, Some(big), "a 30 KB embedded logo is kept");
|
||||
let huge = format!("data:image/png;base64,{}", "A".repeat(70_000));
|
||||
assert_eq!(TabState::reported("tab-1".into(), None, None, Some(huge), None).favicon, None);
|
||||
let long_url = format!("https://x.com/{}", "a".repeat(3000));
|
||||
assert_eq!(TabState::reported("tab-1".into(), None, None, Some(long_url), None).favicon, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue