Skip to content
Snippets Groups Projects
Commit 3e93b9a6 authored by Tim's avatar Tim
Browse files

hide iframes in sanitizer with noImage, fix #872

parent 8cf48bc9
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ const iframeWhitelist = [ ...@@ -28,7 +28,7 @@ const iframeWhitelist = [
} }
} }
]; ];
export const noImageText = '(Image not shown due to low ratings)' export const noImageText = '(Media not shown due to low ratings)'
export const allowedTags = ` export const allowedTags = `
div, iframe, del, div, iframe, del,
a, p, b, q, br, ul, li, ol, img, h1, h2, h3, h4, h5, h6, hr, a, p, b, q, br, ul, li, ol, img, h1, h2, h3, h4, h5, h6, hr,
...@@ -57,6 +57,7 @@ export default ({large = true, highQualityPost = true, noImage = false, sanitize ...@@ -57,6 +57,7 @@ export default ({large = true, highQualityPost = true, noImage = false, sanitize
}, },
transformTags: { transformTags: {
iframe: (tagName, attribs) => { iframe: (tagName, attribs) => {
if(noImage) return {tagName: 'div', text: noImageText}
const srcAtty = attribs.src; const srcAtty = attribs.src;
for(const item of iframeWhitelist) for(const item of iframeWhitelist)
if(item.re.test(srcAtty)) { if(item.re.test(srcAtty)) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment