aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/renderer/html-renderer.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-14 16:48:38 +0100
committerChocobozzz <me@florianbigard.com>2019-01-14 16:48:38 +0100
commit1506307f2f903ce0f80155072a33345c702b7c76 (patch)
tree2bd9620c9ac49c1fc167bb09114f6a5fab049704 /client/src/app/shared/renderer/html-renderer.service.ts
parent9a39392a7e6b3f180104856a4ea893e5baf86a02 (diff)
downloadPeerTube-1506307f2f903ce0f80155072a33345c702b7c76.tar.gz
PeerTube-1506307f2f903ce0f80155072a33345c702b7c76.tar.zst
PeerTube-1506307f2f903ce0f80155072a33345c702b7c76.zip
Increase abuse length to 3000
And correctly handle new lines
Diffstat (limited to 'client/src/app/shared/renderer/html-renderer.service.ts')
-rw-r--r--client/src/app/shared/renderer/html-renderer.service.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/client/src/app/shared/renderer/html-renderer.service.ts b/client/src/app/shared/renderer/html-renderer.service.ts
new file mode 100644
index 000000000..d49df9b6d
--- /dev/null
+++ b/client/src/app/shared/renderer/html-renderer.service.ts
@@ -0,0 +1,35 @@
1import { Injectable } from '@angular/core'
2import { LinkifierService } from '@app/shared/renderer/linkifier.service'
3import * as sanitizeHtml from 'sanitize-html'
4
5@Injectable()
6export class HtmlRendererService {
7
8 constructor (private linkifier: LinkifierService) {
9
10 }
11
12 toSafeHtml (text: string) {
13 // Convert possible markdown to html
14 const html = this.linkifier.linkify(text)
15
16 return sanitizeHtml(html, {
17 allowedTags: [ 'a', 'p', 'span', 'br' ],
18 allowedSchemes: [ 'http', 'https' ],
19 allowedAttributes: {
20 'a': [ 'href', 'class', 'target' ]
21 },
22 transformTags: {
23 a: (tagName, attribs) => {
24 return {
25 tagName,
26 attribs: Object.assign(attribs, {
27 target: '_blank',
28 rel: 'noopener noreferrer'
29 })
30 }
31 }
32 }
33 })
34 }
35}