deduplicate admin HTML escaping
This commit is contained in:
parent
acbd42aa43
commit
03285532cb
1 changed files with 11 additions and 21 deletions
|
|
@ -2,6 +2,11 @@
|
|||
// ADMIN.JS — Admin panel: users, settings, stats
|
||||
// ============================================================
|
||||
|
||||
function adminEscapeHtml(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
(function() {
|
||||
|
||||
var loaded = false;
|
||||
|
|
@ -253,10 +258,7 @@
|
|||
.catch(function() { showToast('Request failed', 'error'); });
|
||||
}
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
var esc = adminEscapeHtml;
|
||||
|
||||
})();
|
||||
|
||||
|
|
@ -830,7 +832,7 @@
|
|||
}
|
||||
function getValue(id) { var el = document.getElementById(id); return el ? el.value.trim() : ''; }
|
||||
function setValue(id, value) { var el = document.getElementById(id); if (el) el.value = value; }
|
||||
function escAssistant(str) { return String(str || '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); }
|
||||
var escAssistant = adminEscapeHtml;
|
||||
})();
|
||||
|
||||
// ============================================================
|
||||
|
|
@ -863,10 +865,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
var esc = adminEscapeHtml;
|
||||
|
||||
function loadAdminModels() {
|
||||
fetch('/api/admin/config/models', { headers: getAuthHeaders() })
|
||||
|
|
@ -1194,10 +1193,7 @@
|
|||
if (e.target.id === 'admin-tts-search' && e.key === 'Enter') { e.preventDefault(); discoverTTS(); }
|
||||
});
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
var esc = adminEscapeHtml;
|
||||
|
||||
function loadTTSConfig() {
|
||||
fetch('/api/admin/config/tts', { headers: getAuthHeaders() })
|
||||
|
|
@ -1382,10 +1378,7 @@
|
|||
if (e.target.id === 'admin-stt-search' && e.key === 'Enter') { e.preventDefault(); discoverSTT(); }
|
||||
});
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
var esc = adminEscapeHtml;
|
||||
|
||||
function loadSTTConfig() {
|
||||
fetch('/api/admin/config/stt', { headers: getAuthHeaders() })
|
||||
|
|
@ -1568,10 +1561,7 @@
|
|||
if (e.target.id === 'admin-embed-search' && e.key === 'Enter') { e.preventDefault(); discoverEmbeddings(); }
|
||||
});
|
||||
|
||||
function esc(str) {
|
||||
if (!str) return '';
|
||||
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
}
|
||||
var esc = adminEscapeHtml;
|
||||
|
||||
function loadEmbeddingConfig() {
|
||||
fetch('/api/admin/config/embeddings', { headers: getAuthHeaders() })
|
||||
|
|
|
|||
Loading…
Reference in a new issue