Fix: Robust web password handling for insight images
This commit is contained in:
@@ -1041,14 +1041,17 @@
|
|||||||
const panel = document.getElementById('insights-panel');
|
const panel = document.getElementById('insights-panel');
|
||||||
if (!panel) return;
|
if (!panel) return;
|
||||||
|
|
||||||
|
// Garante que temos a senha (tenta pegar do global ou do localStorage se precisar)
|
||||||
|
const activePwd = webPassword || localStorage.getItem('vps_web_password') || '';
|
||||||
|
|
||||||
// Transforma caminhos da VPS ( em links da nossa API segura
|
// Transforma caminhos da VPS ( em links da nossa API segura
|
||||||
// Ex: /host_root/root/img.jpg -> /api/host_file?pwd=...&path=/host_root/root/img.jpg
|
// Ex: /host_root/root/img.jpg -> /api/host_file?pwd=...&path=/host_root/root/img.jpg
|
||||||
let mdWithAuth = markdown.replace(/!\[(.*?)\]\((\/host_root\/.*?)\)/g, (match, alt, path) => {
|
let mdWithAuth = markdown.replace(/!\[(.*?)\]\((\/host_root\/.*?)\)/g, (match, alt, path) => {
|
||||||
return `}&path=${encodeURIComponent(path)})`;
|
return `}&path=${encodeURIComponent(path)})`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fallback para qualquer outro caso que tenha sobrado do prefixo antigo
|
// Fallback para qualquer outro caso que tenha sobrado do prefixo antigo
|
||||||
mdWithAuth = mdWithAuth.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(webPassword) + '&path=');
|
mdWithAuth = mdWithAuth.replace(/\/api\/host_file\?path=/g, '/api/host_file?pwd=' + encodeURIComponent(activePwd) + '&path=');
|
||||||
|
|
||||||
// Renderiza o Markdown para HTML usando marked.js
|
// Renderiza o Markdown para HTML usando marked.js
|
||||||
panel.innerHTML = `<div class="animate-fade-in">${marked.parse(mdWithAuth)}</div>`;
|
panel.innerHTML = `<div class="animate-fade-in">${marked.parse(mdWithAuth)}</div>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user