fix: open points after the PR merges
- Office, OneNote, sip and callto links open again - uninstall removes the menu icons from hicolor - peek details are fetched on every open and clear a removed location or attendees - href sanitizer removed, the link hook guards the scheme Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@@ -112,6 +112,9 @@ pub fn uninstall(layout: &Layout) -> io::Result<()> {
112
112
if install_dir.join("update").is_dir() {
113
113
fs::remove_dir_all(install_dir.join("update"))?;
114
114
}
115
for size in ICON_SIZES {
116
remove(layout.icon_file(size))?;
117
}
115
118
// Only when empty: anything else in there belongs to the user.
116
119
let _ = fs::remove_dir(&install_dir);
117
120
refresh_desktop_caches(layout);
@@ -360,6 +363,7 @@ mod tests {
360
363
361
364
assert!(!layout.desktop_file().exists());
362
365
assert!(!layout.install_dir().exists());
366
assert!(!layout.largest_icon().exists());
363
367
uninstall(&layout).unwrap();
364
368
365
369
fs::create_dir_all(layout.install_dir()).unwrap();
@@ -112,6 +112,9 @@ pub fn uninstall(layout: &Layout) -> io::Result<()> {112
if install_dir.join("update").is_dir() {112
if install_dir.join("update").is_dir() {113
fs::remove_dir_all(install_dir.join("update"))?;113
fs::remove_dir_all(install_dir.join("update"))?;114
}114
}115
for size in ICON_SIZES {116
remove(layout.icon_file(size))?;117
}115
// Only when empty: anything else in there belongs to the user.118
// Only when empty: anything else in there belongs to the user.116
let _ = fs::remove_dir(&install_dir);119
let _ = fs::remove_dir(&install_dir);117
refresh_desktop_caches(layout);120
refresh_desktop_caches(layout);@@ -360,6 +363,7 @@ mod tests {360
363
361
assert!(!layout.desktop_file().exists());364
assert!(!layout.desktop_file().exists());362
assert!(!layout.install_dir().exists());365
assert!(!layout.install_dir().exists());366
assert!(!layout.largest_icon().exists());363
uninstall(&layout).unwrap();367
uninstall(&layout).unwrap();364
368
365
fs::create_dir_all(layout.install_dir()).unwrap();369
fs::create_dir_all(layout.install_dir()).unwrap();@@ -345,15 +345,6 @@ impl AppState {
345
345
self.calendar_event_peek_request.take()
346
346
}
347
347
348
pub fn needs_event_details(event: &CalendarEvent) -> bool {
349
event.source == chatsvc::CalendarSource::Outlook
350
&& (event.location.is_none()
351
|| event.body_html.is_none()
352
|| event.attendees.is_empty()
353
|| event.response_counts.is_none()
354
|| (event.series && event.series_master_id.is_none()))
355
}
356
357
348
pub fn apply_calendar_event_details(
358
349
&mut self,
359
350
event_key: &str,
@@ -383,7 +374,7 @@ impl AppState {
383
374
else {
384
375
return;
385
376
};
386
if !Self::needs_event_details(&event) {
377
if event.source != chatsvc::CalendarSource::Outlook {
387
378
return;
388
379
}
389
380
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);
@@ -345,15 +345,6 @@ impl AppState {345
self.calendar_event_peek_request.take()345
self.calendar_event_peek_request.take()346
}346
}347
347
348
pub fn needs_event_details(event: &CalendarEvent) -> bool {349
event.source == chatsvc::CalendarSource::Outlook350
&& (event.location.is_none()351
|| event.body_html.is_none()352
|| event.attendees.is_empty()353
|| event.response_counts.is_none()354
|| (event.series && event.series_master_id.is_none()))355
}356
357
pub fn apply_calendar_event_details(348
pub fn apply_calendar_event_details(358
&mut self,349
&mut self,359
event_key: &str,350
event_key: &str,@@ -383,7 +374,7 @@ impl AppState {383
else {374
else {384
return;375
return;385
};376
};386
if !Self::needs_event_details(&event) {377
if event.source != chatsvc::CalendarSource::Outlook {387
return;378
return;388
}379
}389
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);380
let launcher = self.call_launcher.clone().filter(|_| !self.mode.demo);@@ -17,7 +17,24 @@ pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bo
17
17
}
18
18
}
19
19
20
const OPENABLE_SCHEMES: [&str; 5] = ["https://", "http://", "mailto:", "tel:", "msteams:"];
20
const OPENABLE_SCHEMES: [&str; 16] = [
21
"https://",
22
"http://",
23
"mailto:",
24
"tel:",
25
"sip:",
26
"callto:",
27
"msteams:",
28
"onenote:",
29
"ms-word:",
30
"ms-excel:",
31
"ms-powerpoint:",
32
"ms-visio:",
33
"ms-access:",
34
"ms-project:",
35
"ms-publisher:",
36
"ms-infopath:",
37
];
21
38
22
39
pub fn is_openable_link(url: &str) -> bool {
23
40
let lower = url.trim_start().to_ascii_lowercase();
@@ -57,6 +74,9 @@ mod tests {
57
74
assert!(is_openable_link(" HTTP://example.test"));
58
75
assert!(is_openable_link("mailto:someone@example.test"));
59
76
assert!(is_openable_link("msteams:/l/chat/0/0"));
77
assert!(is_openable_link(
78
"ms-word:ofe|u|https://example.test/a.docx"
79
));
60
80
assert!(!is_openable_link("file:///etc/passwd"));
61
81
assert!(!is_openable_link("search-ms:query=x"));
62
82
assert!(!is_openable_link("javascript:alert(1)"));
@@ -17,7 +17,24 @@ pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bo17
}17
}18
}18
}19
19
20
const OPENABLE_SCHEMES: [&str; 5] = ["https://", "http://", "mailto:", "tel:", "msteams:"];20
const OPENABLE_SCHEMES: [&str; 16] = [21
"https://",22
"http://",23
"mailto:",24
"tel:",25
"sip:",26
"callto:",27
"msteams:",28
"onenote:",29
"ms-word:",30
"ms-excel:",31
"ms-powerpoint:",32
"ms-visio:",33
"ms-access:",34
"ms-project:",35
"ms-publisher:",36
"ms-infopath:",37
];21
38
22
pub fn is_openable_link(url: &str) -> bool {39
pub fn is_openable_link(url: &str) -> bool {23
let lower = url.trim_start().to_ascii_lowercase();40
let lower = url.trim_start().to_ascii_lowercase();@@ -57,6 +74,9 @@ mod tests {57
assert!(is_openable_link(" HTTP://example.test"));74
assert!(is_openable_link(" HTTP://example.test"));58
assert!(is_openable_link("mailto:someone@example.test"));75
assert!(is_openable_link("mailto:someone@example.test"));59
assert!(is_openable_link("msteams:/l/chat/0/0"));76
assert!(is_openable_link("msteams:/l/chat/0/0"));77
assert!(is_openable_link(78
"ms-word:ofe|u|https://example.test/a.docx"79
));60
assert!(!is_openable_link("file:///etc/passwd"));80
assert!(!is_openable_link("file:///etc/passwd"));61
assert!(!is_openable_link("search-ms:query=x"));81
assert!(!is_openable_link("search-ms:query=x"));62
assert!(!is_openable_link("javascript:alert(1)"));82
assert!(!is_openable_link("javascript:alert(1)"));@@ -429,47 +429,7 @@ fn body_html_text(entry: &Value) -> Option<String> {
429
429
.replace('\n', "<br>");
430
430
return Some(escaped);
431
431
}
432
// Drop non-http(s)/mailto hrefs so the agenda renderer cannot open them.
433
Some(sanitize_html_hrefs(&content))
434
}
435
436
fn sanitize_html_hrefs(html: &str) -> String {
437
let mut out = String::with_capacity(html.len());
438
let mut rest = html;
439
while let Some(start) = rest.find("href=") {
440
out.push_str(&rest[..start]);
441
rest = &rest[start..];
442
let quote = rest.as_bytes().get(5).copied();
443
let (quote_char, after_quote) = match quote {
444
Some(b'"') | Some(b'\'') => (quote.unwrap() as char, &rest[6..]),
445
_ => {
446
out.push_str("href=");
447
rest = &rest[5..];
448
continue;
449
}
450
};
451
let Some(end) = after_quote.find(quote_char) else {
452
out.push_str(rest);
453
return out;
454
};
455
let url = &after_quote[..end];
456
let safe = url_is_safe_href(url);
457
out.push_str("href=");
458
out.push(quote_char);
459
if safe {
460
out.push_str(url);
461
}
462
out.push(quote_char);
463
rest = &after_quote[end + 1..];
464
}
465
out.push_str(rest);
466
out
467
}
468
469
fn url_is_safe_href(url: &str) -> bool {
470
let trimmed = url.trim();
471
let lower = trimmed.to_ascii_lowercase();
472
lower.starts_with("https://") || lower.starts_with("http://") || lower.starts_with("mailto:")
432
Some(content)
473
433
}
474
434
475
435
fn attendee_response(label: &str) -> ResponseType {
@@ -620,8 +580,8 @@ pub fn response_counts_from_attendees(entry: &Value) -> Option<AttendeeResponseC
620
580
621
581
/// Merge Graph / detail fields into a calendar event without wiping list data.
622
582
pub fn apply_event_details(event: &mut CalendarEvent, entry: &Value) {
623
if let Some(location) = location_text(entry) {
624
event.location = Some(location);
583
if entry.get("location").is_some() || entry.get("locationDisplayName").is_some() {
584
event.location = location_text(entry);
625
585
}
626
586
if let Some(preview) = body_preview_text(entry) {
627
587
event.body_preview = Some(preview);
@@ -636,12 +596,9 @@ pub fn apply_event_details(event: &mut CalendarEvent, entry: &Value) {
636
596
event.series_master_id = Some(master);
637
597
event.series = true;
638
598
}
639
if let Some(counts) = response_counts_from_attendees(entry) {
640
event.response_counts = Some(counts);
641
}
642
let attendees = attendees_from_entry(entry);
643
if !attendees.is_empty() {
644
event.attendees = attendees;
599
if entry.get("attendees").is_some_and(Value::is_array) {
600
event.response_counts = response_counts_from_attendees(entry);
601
event.attendees = attendees_from_entry(entry);
645
602
}
646
603
if let Some(name) = entry
647
604
.pointer("/organizer/emailAddress/name")
@@ -900,26 +857,32 @@ mod tests {
900
857
}
901
858
902
859
#[test]
903
fn html_body_drops_javascript_hrefs() {
860
fn details_clear_a_removed_location_and_attendees() {
904
861
let mut event = CalendarEvent {
905
object_id: "js".into(),
906
start: Utc.with_ymd_and_hms(2026, 10, 12, 8, 30, 0).unwrap(),
907
end: Utc.with_ymd_and_hms(2026, 10, 12, 9, 0, 0).unwrap(),
862
object_id: "stale".into(),
863
location: Some("Room 1".into()),
864
attendees: vec![EventAttendee {
865
name: "Someone".into(),
866
address: None,
867
response: ResponseType::Accepted,
868
required: true,
869
}],
870
response_counts: Some(AttendeeResponseCounts {
871
accepted: 1,
872
..Default::default()
873
}),
908
874
..Default::default()
909
875
};
876
apply_event_details(&mut event, &serde_json::json!({"subject": "kept"}));
877
assert_eq!(event.location.as_deref(), Some("Room 1"));
878
assert_eq!(event.attendees.len(), 1);
910
879
apply_event_details(
911
880
&mut event,
912
&serde_json::json!({
913
"body": {
914
"contentType": "html",
915
"content": r#"<p><a href="javascript:alert(1)">x</a> <a href='https://ok.example'>y</a></p>"#
916
}
917
}),
881
&serde_json::json!({"location": {"displayName": ""}, "attendees": []}),
918
882
);
919
let html = event.body_html.as_deref().expect("html");
920
assert!(!html.to_ascii_lowercase().contains("javascript:"));
921
assert!(html.contains(r#"href="""#) || html.contains("href=''"));
922
assert!(html.contains(r#"href='https://ok.example'"#));
883
assert_eq!(event.location, None);
884
assert!(event.attendees.is_empty());
885
assert_eq!(event.response_counts, None);
923
886
}
924
887
925
888
#[test]
@@ -429,47 +429,7 @@ fn body_html_text(entry: &Value) -> Option<String> {429
.replace('\n', "<br>");429
.replace('\n', "<br>");430
return Some(escaped);430
return Some(escaped);431
}431
}432
// Drop non-http(s)/mailto hrefs so the agenda renderer cannot open them.432
Some(content)433
Some(sanitize_html_hrefs(&content))434
}435
436
fn sanitize_html_hrefs(html: &str) -> String {437
let mut out = String::with_capacity(html.len());438
let mut rest = html;439
while let Some(start) = rest.find("href=") {440
out.push_str(&rest[..start]);441
rest = &rest[start..];442
let quote = rest.as_bytes().get(5).copied();443
let (quote_char, after_quote) = match quote {444
Some(b'"') | Some(b'\'') => (quote.unwrap() as char, &rest[6..]),445
_ => {446
out.push_str("href=");447
rest = &rest[5..];448
continue;449
}450
};451
let Some(end) = after_quote.find(quote_char) else {452
out.push_str(rest);453
return out;454
};455
let url = &after_quote[..end];456
let safe = url_is_safe_href(url);457
out.push_str("href=");458
out.push(quote_char);459
if safe {460
out.push_str(url);461
}462
out.push(quote_char);463
rest = &after_quote[end + 1..];464
}465
out.push_str(rest);466
out467
}468
469
fn url_is_safe_href(url: &str) -> bool {470
let trimmed = url.trim();471
let lower = trimmed.to_ascii_lowercase();472
lower.starts_with("https://") || lower.starts_with("http://") || lower.starts_with("mailto:")473
}433
}474
434
475
fn attendee_response(label: &str) -> ResponseType {435
fn attendee_response(label: &str) -> ResponseType {@@ -620,8 +580,8 @@ pub fn response_counts_from_attendees(entry: &Value) -> Option<AttendeeResponseC620
580
621
/// Merge Graph / detail fields into a calendar event without wiping list data.581
/// Merge Graph / detail fields into a calendar event without wiping list data.622
pub fn apply_event_details(event: &mut CalendarEvent, entry: &Value) {582
pub fn apply_event_details(event: &mut CalendarEvent, entry: &Value) {623
if let Some(location) = location_text(entry) {583
if entry.get("location").is_some() || entry.get("locationDisplayName").is_some() {624
event.location = Some(location);584
event.location = location_text(entry);625
}585
}626
if let Some(preview) = body_preview_text(entry) {586
if let Some(preview) = body_preview_text(entry) {627
event.body_preview = Some(preview);587
event.body_preview = Some(preview);@@ -636,12 +596,9 @@ pub fn apply_event_details(event: &mut CalendarEvent, entry: &Value) {636
event.series_master_id = Some(master);596
event.series_master_id = Some(master);637
event.series = true;597
event.series = true;638
}598
}639
if let Some(counts) = response_counts_from_attendees(entry) {599
if entry.get("attendees").is_some_and(Value::is_array) {640
event.response_counts = Some(counts);600
event.response_counts = response_counts_from_attendees(entry);641
}601
event.attendees = attendees_from_entry(entry);642
let attendees = attendees_from_entry(entry);643
if !attendees.is_empty() {644
event.attendees = attendees;645
}602
}646
if let Some(name) = entry603
if let Some(name) = entry647
.pointer("/organizer/emailAddress/name")604
.pointer("/organizer/emailAddress/name")@@ -900,26 +857,32 @@ mod tests {900
}857
}901
858
902
#[test]859
#[test]903
fn html_body_drops_javascript_hrefs() {860
fn details_clear_a_removed_location_and_attendees() {904
let mut event = CalendarEvent {861
let mut event = CalendarEvent {905
object_id: "js".into(),862
object_id: "stale".into(),906
start: Utc.with_ymd_and_hms(2026, 10, 12, 8, 30, 0).unwrap(),863
location: Some("Room 1".into()),907
end: Utc.with_ymd_and_hms(2026, 10, 12, 9, 0, 0).unwrap(),864
attendees: vec![EventAttendee {865
name: "Someone".into(),866
address: None,867
response: ResponseType::Accepted,868
required: true,869
}],870
response_counts: Some(AttendeeResponseCounts {871
accepted: 1,872
..Default::default()873
}),908
..Default::default()874
..Default::default()909
};875
};876
apply_event_details(&mut event, &serde_json::json!({"subject": "kept"}));877
assert_eq!(event.location.as_deref(), Some("Room 1"));878
assert_eq!(event.attendees.len(), 1);910
apply_event_details(879
apply_event_details(911
&mut event,880
&mut event,912
&serde_json::json!({881
&serde_json::json!({"location": {"displayName": ""}, "attendees": []}),913
"body": {914
"contentType": "html",915
"content": r#"<p><a href="javascript:alert(1)">x</a> <a href='https://ok.example'>y</a></p>"#916
}917
}),918
);882
);919
let html = event.body_html.as_deref().expect("html");883
assert_eq!(event.location, None);920
assert!(!html.to_ascii_lowercase().contains("javascript:"));884
assert!(event.attendees.is_empty());921
assert!(html.contains(r#"href="""#) || html.contains("href=''"));885
assert_eq!(event.response_counts, None);922
assert!(html.contains(r#"href='https://ok.example'"#));923
}886
}924
887
925
#[test]888
#[test]