Your one-stop-cake-shop for everything Freshly Baked has to offer

fix(m): correct shortlink resolution escaping #191

closed opened by a.starrysky.fyi targeting main from private/minion/push-rvvlvvqouvzu

Previously we were escaping shortlinks before resolving them (and in-fact doing that twice!). That's wrong, we should instead be escaping the parameter for our default links but not escaping the resolved shortlinks (as for direct they are replaced entirely with created shortlinks and for regex the character set can be very restricted for matches).

Escaping as we were prevented links like a/b working

Labels

None yet.

requested-reviewers

None yet.

approved

None yet.

tested-working

None yet.

rejected

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:uuyqs6y3pwtbteet4swt5i5y/sh.tangled.repo.pull/3mdjm43jsyl22
+2 -8
Diff #0
+2 -8
menu/src/main.rs
··· 60 60 } 61 61 62 62 async fn get_redirect(go: &str) -> Option<Redirect> { 63 - let go = &utf8_percent_encode(go, NON_ALPHANUMERIC).to_string(); 64 - 65 63 if let Some(redirect) = direct::get_redirect(go).await { 66 64 return Some(redirect); 67 65 } ··· 74 72 } 75 73 76 74 async fn get_redirect_base(go: &str) -> Redirect { 77 - let go = &utf8_percent_encode(go, NON_ALPHANUMERIC).to_string(); 78 - 79 75 get_redirect(go) 80 76 .await 81 - .unwrap_or_else(|| Redirect::temporary(&("/_/create?format=direct&from=".to_string() + go))) 77 + .unwrap_or_else(|| Redirect::temporary(&("/_/create?format=direct&from=".to_string() + &utf8_percent_encode(go, NON_ALPHANUMERIC).to_string()))) 82 78 } 83 79 84 80 async fn get_redirect_search(go: &str) -> Redirect { 85 - let go = &utf8_percent_encode(go, NON_ALPHANUMERIC).to_string(); 86 - 87 81 get_redirect(go) 88 82 .await 89 - .unwrap_or_else(|| Redirect::temporary(&("https://kagi.com/search?q=".to_string() + go))) 83 + .unwrap_or_else(|| Redirect::temporary(&("https://kagi.com/search?q=".to_string() + &utf8_percent_encode(go, NON_ALPHANUMERIC).to_string()))) 90 84 } 91 85 92 86 #[axum::debug_handler]

History

1 round 0 comments
sign up or login to add to the discussion
a.starrysky.fyi submitted #0
1 commit
expand
fix(m): correct shortlink resolution escaping
5/5 success
expand
expand 0 comments
closed without merging