Skip to content

Commit ba7ce9d

Browse files
authored
feat: allow adding twitter embeds (#340)
1 parent 24997fa commit ba7ce9d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

libs/blog-bff/articles/api/src/lib/mappers.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ export const toArticle = (dto?: WPPostDetailsDto): Article => {
4545
const title = cheerio.load(dto.title.rendered || '');
4646

4747
const content = sanitizeHtml(dto?.content.rendered || '', {
48-
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'iframe']),
48+
allowedTags: sanitizeHtml.defaults.allowedTags.concat([
49+
'img',
50+
'iframe',
51+
'script',
52+
]),
53+
allowVulnerableTags: true,
54+
allowedScriptHostnames: ['platform.twitter.com'],
4955
allowedAttributes: {
5056
img: [
5157
'src',
@@ -60,8 +66,10 @@ export const toArticle = (dto?: WPPostDetailsDto): Article => {
6066
],
6167
a: ['href'],
6268
iframe: ['src'],
69+
script: ['src', 'async', 'charset'],
6370
},
6471
allowedClasses: {
72+
blockquote: ['twitter-tweet'],
6573
pre: ['lang:*'],
6674
div: ['crayon-line', 'crayon-syntax'],
6775
},

0 commit comments

Comments
 (0)