diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-08-20 22:06:17 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-08-20 22:07:50 -0300 |
commit | 93fd751aeb3a9c0b60889db0073e7907c87f90fe (patch) | |
tree | dbf9efedc019a0ce27d37eb40e92922efee2e3f7 /src | |
parent | 040e0d3a1d3890f7c45e2839ca949d353a160efc (diff) |
content: linkTemplate: strip <a> tags from content
Diffstat (limited to 'src')
-rw-r--r-- | src/content/dependencies/linkTemplate.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/content/dependencies/linkTemplate.js b/src/content/dependencies/linkTemplate.js index ed88cacf..1cf64c59 100644 --- a/src/content/dependencies/linkTemplate.js +++ b/src/content/dependencies/linkTemplate.js @@ -1,5 +1,7 @@ import {empty} from '#sugar'; +import striptags from 'striptags'; + export default { extraDependencies: [ 'appendIndexHTML', @@ -59,15 +61,18 @@ export default { title = slots.tooltip; } - return html.tag('a', - { - ...slots.attributes ?? {}, - href, - style, - title, - }, + const content = (html.isBlank(slots.content) ? language.$('misc.missingLinkContent') - : slots.content)); + : striptags(html.resolve(slots.content, {normalize: 'string'}), { + disallowedTags: new Set(['a']), + })); + + return html.tag('a', { + ...slots.attributes ?? {}, + href, + style, + title, + }, content); }, } |