fix: restrict ticker article links to http(s)
This commit is contained in:
@@ -958,6 +958,7 @@ function renderRight(){
|
||||
// === HELPERS ===
|
||||
function getAge(d){const ms=Date.now()-new Date(d).getTime();const h=Math.floor(ms/3600000);if(h<1)return 'just now';if(h<24)return h+'h ago';return Math.floor(h/24)+'d ago'}
|
||||
function cleanText(t){return t.replace(/'/g,"'").replace(/!/g,"!").replace(/&/g,"&").replace(/<[^>]+>/g,'')}
|
||||
function safeExternalUrl(raw){try{const u=new URL(raw,location.href);return u.protocol==='http:'||u.protocol==='https:'?u.toString():null}catch{return null}}
|
||||
|
||||
// === BOOT SEQUENCE ===
|
||||
function runBoot(){
|
||||
@@ -1055,7 +1056,10 @@ function init(){
|
||||
// Open article links from ticker cards
|
||||
document.addEventListener('click',e=>{
|
||||
const card=e.target.closest('.tk-card[data-url]');
|
||||
if(card) window.open(card.dataset.url,'_blank','noopener');
|
||||
if(card){
|
||||
const url=safeExternalUrl(card.dataset.url);
|
||||
if(url) window.open(url,'_blank','noopener');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user