mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Refactor markdown/sanitize html code
This commit is contained in:
parent
9afb5c10e5
commit
9ff36c2d70
7 changed files with 67 additions and 70 deletions
21
shared/core-utils/renderer/html.ts
Normal file
21
shared/core-utils/renderer/html.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
export const SANITIZE_OPTIONS = {
|
||||
allowedTags: [ 'a', 'p', 'span', 'br', 'strong', 'em', 'ul', 'ol', 'li' ],
|
||||
allowedSchemes: [ 'http', 'https' ],
|
||||
allowedAttributes: {
|
||||
a: [ 'href', 'class', 'target', 'rel' ]
|
||||
},
|
||||
transformTags: {
|
||||
a: (tagName, attribs) => {
|
||||
let rel = 'noopener noreferrer'
|
||||
if (attribs.rel === 'me') rel += ' me'
|
||||
|
||||
return {
|
||||
tagName,
|
||||
attribs: Object.assign(attribs, {
|
||||
target: '_blank',
|
||||
rel
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue