mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
fix: PO parser escape order, proxy endpoint consistency, and accessibility bugs
This commit is contained in:
+2
-2
@@ -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(
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-4
@@ -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 '<i class="icon-check bool-true" aria-hidden="true"></i>';
|
||||
return '<i class="icon-check bool-true" aria-hidden="true"></i><span class="sr-only">'+escapeHtml(yesText)+'</span>';
|
||||
}
|
||||
return '<i class="icon-minus bool-false" aria-hidden="true"></i>';
|
||||
return '<i class="icon-minus bool-false" aria-hidden="true"></i><span class="sr-only">'+escapeHtml(noText)+'</span>';
|
||||
}
|
||||
|
||||
function labelFor(key){
|
||||
@@ -252,7 +255,7 @@ function initCopyIp(wrap){
|
||||
html+='<span class="ip-copied-tooltip" aria-live="polite" hidden>'+escapeHtml(copiedText)+'</span>';
|
||||
html+='</div>';
|
||||
|
||||
html+='<table class="info-table"><tbody>';
|
||||
html+='<table class="info-table" aria-label="'+escapeHtml(tableLabel)+'"><tbody>';
|
||||
|
||||
var asn=info.asn||{};
|
||||
var asnNum=asn.autonomous_system_number;
|
||||
@@ -359,8 +362,11 @@ function initCopyIp(wrap){
|
||||
})
|
||||
.catch(function(){hideSkeleton();});
|
||||
}else if(!primaryIsIPv6){
|
||||
fetch("/ip")
|
||||
var controller2=new AbortController();
|
||||
var timeout2=setTimeout(function(){controller2.abort();},5000);
|
||||
fetch("/ip",{signal:controller2.signal})
|
||||
.then(function(r){
|
||||
clearTimeout(timeout2);
|
||||
if(!r.ok)throw new Error(r.status);
|
||||
return r.text();
|
||||
})
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ main {
|
||||
|
||||
.ip-copied-tooltip {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
inset-inline-end: 0;
|
||||
top: 50%;
|
||||
translate: 0 -50%;
|
||||
font-size: 13px;
|
||||
|
||||
@@ -67,6 +67,9 @@
|
||||
<div itemscope itemtype="https://schema.org/WebPage"
|
||||
data-ipv4-domain="{{ ipv4_domain }}"
|
||||
data-copied-text="{{ "Copied"|t(locale) }}"
|
||||
data-yes-text="{{ "Yes"|t(locale) }}"
|
||||
data-no-text="{{ "No"|t(locale) }}"
|
||||
data-table-label="{{ "IP address information"|t(locale) }}"
|
||||
{% if is_query %}data-is-query="true"{% endif %}
|
||||
id="ip-info-root">
|
||||
<div class="ip-copy-wrap" data-copied="{{ "Copied"|t(locale) }}">
|
||||
|
||||
Reference in New Issue
Block a user