From 87603a9adf7762027a1defd8ea1ef498afc2fa63 Mon Sep 17 00:00:00 2001 From: anor Date: Tue, 9 Jun 2026 17:55:25 +1000 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D0=B2=D0=B5=D1=82=D0=B0=D1=85=20=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BD=D1=82=D0=B0=20=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D1=80=D1=8B=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=B2=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Внешние ссылки (источники веб-поиска) получают target=_blank + rel=noopener noreferrer, чтобы клик не уводил из чата. Файловые ссылки-скачивания не затронуты (externalizeLinks вызывается только на AI-сообщениях). --- static/chat.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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();