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

fix(m): correct shortlink resolution escaping

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

+2 -8
+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]