Node.js based forum software built for the modern web
test: allow component in span/a/img for now
Barış Soner Uşaklıa990ba7f903c
diff --git a/src/posts/parse.js b/src/posts/parse.jsindex d6a31b9b99..7260b54837 100644--- a/src/posts/parse.js+++ b/src/posts/parse.js@@ -19,13 +19,14 @@ let sanitizeConfig = {]),allowedAttributes: {...sanitize.defaults.allowedAttributes,- a: ['href', 'name', 'hreflang', 'media', 'rel', 'target', 'type'],- img: ['alt', 'height', 'ismap', 'src', 'usemap', 'width', 'srcset'],+ a: ['href', 'name', 'hreflang', 'media', 'rel', 'target', 'type', 'component'],+ img: ['alt', 'height', 'ismap', 'src', 'usemap', 'width', 'srcset', 'component'],iframe: ['height', 'name', 'src', 'width', 'allow', 'frameborder'],video: ['autoplay', 'playsinline', 'controls', 'height', 'loop', 'muted', 'poster', 'preload', 'src', 'width'],audio: ['autoplay', 'controls', 'loop', 'muted', 'preload', 'src'],source: ['type', 'src', 'srcset', 'sizes', 'media', 'height', 'width'],embed: ['height', 'src', 'type', 'width'],+ span: ['component'],},nonBooleanAttributes: ['accesskey', 'class', 'contenteditable', 'dir','draggable', 'dropzone', 'hidden', 'id', 'lang', 'spellcheck', 'style',diff --git a/test/topics/events.js b/test/topics/events.jsindex b638034e62..7383ae73cb 100644--- a/test/topics/events.js+++ b/test/topics/events.js@@ -127,7 +127,7 @@ describe('Topic Events', () => {const events = await topics.events.get(topicData.tid, uid);- assert.deepStrictEqual(events[0].text, `<span title=""><script>alert("xss")</script> [[global:posts]]" data-uid="${uid}" class="avatar avatar-rounded" component="avatar/icon" style="--avatar-size: 16px; background-color: #827717">B</span> <a href="${nconf.get('relative_path')}/user/bar">"><script>alert("xss")</script> [[global:posts]]</a> <a href="${nconf.get('relative_path')}/topic/${topicData.tid}">forked</a> this topic <span class="timeago timeline-text" title="${new Date(now).toISOString()}"></span>`);+ assert.deepStrictEqual(events[0].text, `<span title=""><script>alert("xss")</script> [[global:posts]]" data-uid="${uid}" class="avatar avatar-rounded" component="avatar/icon" style="--avatar-size:16px;background-color:#827717">B</span> <a href="${nconf.get('relative_path')}/user/bar">"><script>alert("xss")</script> [[global:posts]]</a> <a href="${nconf.get('relative_path')}/topic/${topicData.tid}">forked</a> this topic <span class="timeago timeline-text" title="${new Date(now).toISOString()}"></span>`);meta.config.showFullnameAsDisplayName = oldVlaueShowFullnameAsDisplayName;});@@ -152,6 +152,6 @@ describe('Topic Events', () => {timestamp: now,});const events = await topics.events.get(topicData.tid, uid);- assert.strictEqual(events[0].text, `<span title="barmove" data-uid="${uid}" class="avatar avatar-rounded" component="avatar/icon" style="--avatar-size: 16px; background-color: #33691e">B</span> <a href="/user/barmove">barmove</a> moved this topic from <a component="topic/category" href="/category/2/img-onerror-alert-origin" class="badge px-1 text-truncate text-decoration-none " style="color: ${oldCategory.color};background-color: ${oldCategory.bgColor};border-color: ${oldCategory.bgColor}!important; max-width: 70vw;"> <i class="fa fa-fw hidden"></i> <img onerror=alert(origin)> </a> <span class="timeago timeline-text" title="${new Date(now).toISOString()}"></span>`);+ assert.strictEqual(events[0].text, `<span title="barmove" data-uid="${uid}" class="avatar avatar-rounded" component="avatar/icon" style="--avatar-size:16px;background-color:#33691e">B</span> <a href="/user/barmove">barmove</a> moved this topic from <a component="topic/category" href="/category/${oldCategory.cid}/img-onerror-alert-origin" class="badge px-1 text-truncate text-decoration-none " style="color:${oldCategory.color};background-color:${oldCategory.bgColor};border-color:${oldCategory.bgColor} !important;max-width:70vw"> <i class="fa fa-fw hidden"></i> <img onerror=alert(origin)> </a> <span class="timeago timeline-text" title="${new Date(now).toISOString()}"></span>`);});});