From 93fd751aeb3a9c0b60889db0073e7907c87f90fe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 20 Aug 2023 22:06:17 -0300 Subject: content: linkTemplate: strip tags from content --- src/content/dependencies/linkTemplate.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/content/dependencies/linkTemplate.js') 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); }, } -- cgit 1.3.0-6-gf8a5