diff --git a/src/handlers/api.rs b/src/handlers/api.rs index 607677e..19118d1 100644 --- a/src/handlers/api.rs +++ b/src/handlers/api.rs @@ -81,8 +81,8 @@ fn proxy_field_handler( return Err(AppError::DbNotReady); } let ip = resolve_ip(headers, query, state.dev_mode)?; - let proxy = db::lookup_proxy(&state.db, ip).ok_or(AppError::DbLookupFailed)?; - Ok(format!("{}\n", field(&proxy))) + let value = db::lookup_proxy(&state.db, ip).map_or(false, |p| field(&p)); + Ok(format!("{value}\n")) } pub async fn asn_handler( diff --git a/src/i18n.rs b/src/i18n.rs index 8a639eb..195ab41 100644 --- a/src/i18n.rs +++ b/src/i18n.rs @@ -212,9 +212,10 @@ fn append_quoted(target: &mut String, quoted: &str) { if s.len() >= 2 && s.starts_with('"') && s.ends_with('"') { let inner = &s[1..s.len() - 1]; let unescaped = inner + .replace("\\\\", "\x00") .replace("\\n", "\n") .replace("\\\"", "\"") - .replace("\\\\", "\\"); + .replace('\x00', "\\"); target.push_str(&unescaped); } } diff --git a/static/script.js b/static/script.js index 0b95237..f2162ea 100644 --- a/static/script.js +++ b/static/script.js @@ -208,6 +208,9 @@ function initCopyIp(wrap){ var langTag=document.documentElement.getAttribute("lang")||"en"; var mmdbKeyMap={"en":"en","de":"de","es":"es","fr":"fr","ja":"ja","ru":"ru","pt":"pt-BR","zh-Hans":"zh-CN","zh-Hant":"zh-CN"}; var mmdbKey=mmdbKeyMap[langTag]||"en"; + var yesText=root.getAttribute("data-yes-text")||"Yes"; + var noText=root.getAttribute("data-no-text")||"No"; + var tableLabel=root.getAttribute("data-table-label")||"IP address information"; function localizedName(names){ if(!names)return ""; @@ -237,9 +240,9 @@ function initCopyIp(wrap){ function boolHtml(val){ if(val){ - return ''; + return ''+escapeHtml(yesText)+''; } - return ''; + return ''+escapeHtml(noText)+''; } function labelFor(key){ @@ -252,7 +255,7 @@ function initCopyIp(wrap){ html+=''+escapeHtml(copiedText)+''; html+=''; - html+='