diff --git a/static/chat.html b/static/chat.html
index 6eb568d..7bbb91d 100644
--- a/static/chat.html
+++ b/static/chat.html
@@ -394,6 +394,18 @@ function typografAI(root) {
}
}
+// Внешние ссылки в ответах ассистента (источники веб-поиска) открываем в новой
+// вкладке, чтобы не увести пользователя из чата. rel — против tabnabbing.
+function externalizeLinks(root) {
+ root.querySelectorAll('a[href]').forEach(a => {
+ const h = a.getAttribute('href') || '';
+ if (/^(https?:)?\/\//i.test(h)) {
+ a.target = '_blank';
+ a.rel = 'noopener noreferrer';
+ }
+ });
+}
+
const API = '';
let token = localStorage.getItem('token');
let pendingFiles = [];
@@ -521,6 +533,7 @@ function addMsg(type, text, ts) {
div.prepend(time);
enhanceTables(div);
typografAI(div);
+ externalizeLinks(div);
} else {
div.textContent = text;
div.prepend(time);
@@ -792,7 +805,7 @@ async function sendMessage() {
}
}
if (!aiDiv && !aiText) addMsg('ai', '(пустой ответ)');
- if (aiDiv) { enhanceTables(aiDiv); typografAI(aiDiv); } // streaming re-renders innerHTML each chunk → finalize once at the end
+ if (aiDiv) { enhanceTables(aiDiv); typografAI(aiDiv); externalizeLinks(aiDiv); } // streaming re-renders innerHTML each chunk → finalize once at the end
} catch (err) {
removeTyping();