Use html template tags to escape user input
Merged safe html changes from Steven.
This commit is contained in:
parent
7954c75841
commit
7a3a4077e8
4 changed files with 77 additions and 38 deletions
|
@ -7,21 +7,21 @@ function linkify(text="", show_media=false) {
|
|||
} catch (err) {
|
||||
return match;
|
||||
}
|
||||
let html;
|
||||
let markup;
|
||||
if (show_media && is_img_url(parsed.pathname)) {
|
||||
html = `
|
||||
markup = html`
|
||||
<img class="inline-img clickable" src="${url}" onclick="open_media_preview('${url}', 'image')"/>
|
||||
`;
|
||||
} else if (show_media && is_video_url(parsed.pathname)) {
|
||||
html = `
|
||||
markup = html`
|
||||
<video controls class="inline-img" />
|
||||
<source src="${url}">
|
||||
</video>
|
||||
`;
|
||||
} else {
|
||||
html = `<a target="_blank" rel="noopener noreferrer" href="${url}">${url}</a>`;
|
||||
markup = html`<a target="_blank" rel="noopener noreferrer" href="${url}">${url}</a>`;
|
||||
}
|
||||
return p1+html;
|
||||
return p1+markup;
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue