Embedded links open in new tab

This commit is contained in:
rainbow napkin 2025-05-04 18:48:33 -04:00
parent 1f00bacb6f
commit 7badaa927c

View file

@ -116,6 +116,7 @@ class chatPostprocessor{
const link = document.createElement('a'); const link = document.createElement('a');
link.classList.add('chat-link', ...wordObj.filterClasses); link.classList.add('chat-link', ...wordObj.filterClasses);
link.href = wordObj.link; link.href = wordObj.link;
link.target = "_blank";
//Use textContent to be safe since links can't be escaped serverside //Use textContent to be safe since links can't be escaped serverside
link.textContent = wordObj.link; link.textContent = wordObj.link;
@ -126,6 +127,7 @@ class chatPostprocessor{
const badLink = document.createElement('a'); const badLink = document.createElement('a');
badLink.classList.add('chat-dead-link', 'danger-link', ...wordObj.filterClasses); badLink.classList.add('chat-dead-link', 'danger-link', ...wordObj.filterClasses);
badLink.href = wordObj.link; badLink.href = wordObj.link;
badLink.target = "_blank";
//Use textContent to be safe since links can't be escaped serverside //Use textContent to be safe since links can't be escaped serverside
badLink.textContent = wordObj.link; badLink.textContent = wordObj.link;
@ -213,6 +215,7 @@ class chatPostprocessor{
link.classList.add('chat-link', ...wordObj.filterClasses); link.classList.add('chat-link', ...wordObj.filterClasses);
//Set href and inner text //Set href and inner text
link.href = `/c/${wordObj.chan}`; link.href = `/c/${wordObj.chan}`;
link.target = "_blank"
link.textContent = wordObj.string; link.textContent = wordObj.string;
//We don't have to worry about injecting this into whitespace since there shouldn't be any here. //We don't have to worry about injecting this into whitespace since there shouldn't be any here.