diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-04 17:50:30 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-04 17:50:30 +0100 |
commit | 2890b615f31ab7d519d8be66b49ff8712df90c51 (patch) | |
tree | 4ad6bf366416a1cbc4d39bc8b7747f6d985b4d19 /client | |
parent | c3badc81fe3d78601fb278a7f28eeed63060d300 (diff) | |
download | PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.tar.gz PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.tar.zst PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.zip |
Handle HTML is comments
Diffstat (limited to 'client')
5 files changed, 90 insertions, 6 deletions
diff --git a/client/package.json b/client/package.json index ba0a318bc..efdd5711b 100644 --- a/client/package.json +++ b/client/package.json | |||
@@ -41,6 +41,7 @@ | |||
41 | "@types/lodash-es": "^4.17.0", | 41 | "@types/lodash-es": "^4.17.0", |
42 | "@types/markdown-it": "^0.0.4", | 42 | "@types/markdown-it": "^0.0.4", |
43 | "@types/node": "^8.0.33", | 43 | "@types/node": "^8.0.33", |
44 | "@types/sanitize-html": "^1.14.0", | ||
44 | "@types/video.js": "6.2.0", | 45 | "@types/video.js": "6.2.0", |
45 | "@types/webtorrent": "^0.98.4", | 46 | "@types/webtorrent": "^0.98.4", |
46 | "angular2-notifications": "^0.9.6", | 47 | "angular2-notifications": "^0.9.6", |
@@ -67,6 +68,7 @@ | |||
67 | "raw-loader": "^0.5.1", | 68 | "raw-loader": "^0.5.1", |
68 | "resolve-url-loader": "^2.0.0", | 69 | "resolve-url-loader": "^2.0.0", |
69 | "rxjs": "^5.4.2", | 70 | "rxjs": "^5.4.2", |
71 | "sanitize-html": "^1.16.3", | ||
70 | "sass-loader": "^6.0.3", | 72 | "sass-loader": "^6.0.3", |
71 | "sass-resources-loader": "^1.2.1", | 73 | "sass-resources-loader": "^1.2.1", |
72 | "standard": "^10.0.0", | 74 | "standard": "^10.0.0", |
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html index 4f9597607..8edd12124 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html | |||
@@ -6,7 +6,7 @@ | |||
6 | <a target="_blank" [href]="comment.account.url" class="comment-account">{{ comment.by }}</a> | 6 | <a target="_blank" [href]="comment.account.url" class="comment-account">{{ comment.by }}</a> |
7 | <div class="comment-date">{{ comment.createdAt | myFromNow }}</div> | 7 | <div class="comment-date">{{ comment.createdAt | myFromNow }}</div> |
8 | </div> | 8 | </div> |
9 | <div>{{ comment.text }}</div> | 9 | <div class="comment-html" [innerHTML]="sanitizedCommentHTML"></div> |
10 | 10 | ||
11 | <div class="comment-actions"> | 11 | <div class="comment-actions"> |
12 | <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply">Reply</div> | 12 | <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply">Reply</div> |
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.scss b/client/src/app/videos/+video-watch/comment/video-comment.component.scss index a22c5a9fd..8e53dbca8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.scss +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.scss | |||
@@ -32,6 +32,14 @@ | |||
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | .comment-html { | ||
36 | a { | ||
37 | @include disable-default-a-behaviour; | ||
38 | |||
39 | color: #000; | ||
40 | } | ||
41 | } | ||
42 | |||
35 | .comment-actions { | 43 | .comment-actions { |
36 | margin: 10px 0; | 44 | margin: 10px 0; |
37 | display: flex; | 45 | display: flex; |
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index 9bc9c8844..2ecc8a143 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts | |||
@@ -1,4 +1,5 @@ | |||
1 | import { Component, EventEmitter, Input, Output } from '@angular/core' | 1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' |
2 | import * as sanitizeHtml from 'sanitize-html' | ||
2 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' | 3 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' |
3 | import { UserRight } from '../../../../../../shared/models/users' | 4 | import { UserRight } from '../../../../../../shared/models/users' |
4 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 5 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
@@ -12,7 +13,7 @@ import { VideoComment } from './video-comment.model' | |||
12 | templateUrl: './video-comment.component.html', | 13 | templateUrl: './video-comment.component.html', |
13 | styleUrls: ['./video-comment.component.scss'] | 14 | styleUrls: ['./video-comment.component.scss'] |
14 | }) | 15 | }) |
15 | export class VideoCommentComponent { | 16 | export class VideoCommentComponent implements OnInit { |
16 | @Input() video: Video | 17 | @Input() video: Video |
17 | @Input() comment: VideoComment | 18 | @Input() comment: VideoComment |
18 | @Input() commentTree: VideoCommentThreadTree | 19 | @Input() commentTree: VideoCommentThreadTree |
@@ -23,12 +24,20 @@ export class VideoCommentComponent { | |||
23 | @Output() threadCreated = new EventEmitter<VideoCommentThreadTree>() | 24 | @Output() threadCreated = new EventEmitter<VideoCommentThreadTree>() |
24 | @Output() resetReply = new EventEmitter() | 25 | @Output() resetReply = new EventEmitter() |
25 | 26 | ||
27 | sanitizedCommentHTML = '' | ||
28 | |||
26 | constructor (private authService: AuthService) {} | 29 | constructor (private authService: AuthService) {} |
27 | 30 | ||
28 | get user () { | 31 | get user () { |
29 | return this.authService.getUser() | 32 | return this.authService.getUser() |
30 | } | 33 | } |
31 | 34 | ||
35 | ngOnInit () { | ||
36 | this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, { | ||
37 | allowedTags: [ 'p', 'span' ] | ||
38 | }) | ||
39 | } | ||
40 | |||
32 | onCommentReplyCreated (createdComment: VideoComment) { | 41 | onCommentReplyCreated (createdComment: VideoComment) { |
33 | if (!this.commentTree) { | 42 | if (!this.commentTree) { |
34 | this.commentTree = { | 43 | this.commentTree = { |
diff --git a/client/yarn.lock b/client/yarn.lock index a3928ef40..a0bfa789d 100644 --- a/client/yarn.lock +++ b/client/yarn.lock | |||
@@ -255,6 +255,10 @@ | |||
255 | "@types/node" "*" | 255 | "@types/node" "*" |
256 | "@types/parse-torrent-file" "*" | 256 | "@types/parse-torrent-file" "*" |
257 | 257 | ||
258 | "@types/sanitize-html@^1.14.0": | ||
259 | version "1.14.0" | ||
260 | resolved "https://registry.yarnpkg.com/@types/sanitize-html/-/sanitize-html-1.14.0.tgz#9a03ec58306e24feaa3fbdb8ab593934d53ecb05" | ||
261 | |||
258 | "@types/simple-peer@*": | 262 | "@types/simple-peer@*": |
259 | version "6.1.4" | 263 | version "6.1.4" |
260 | resolved "https://registry.yarnpkg.com/@types/simple-peer/-/simple-peer-6.1.4.tgz#1d1384e1d8dc17b9e7d1673d704febe91ca48191" | 264 | resolved "https://registry.yarnpkg.com/@types/simple-peer/-/simple-peer-6.1.4.tgz#1d1384e1d8dc17b9e7d1673d704febe91ca48191" |
@@ -466,7 +470,7 @@ array-union@^1.0.1: | |||
466 | dependencies: | 470 | dependencies: |
467 | array-uniq "^1.0.1" | 471 | array-uniq "^1.0.1" |
468 | 472 | ||
469 | array-uniq@^1.0.1: | 473 | array-uniq@^1.0.1, array-uniq@^1.0.2: |
470 | version "1.0.3" | 474 | version "1.0.3" |
471 | resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" | 475 | resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" |
472 | 476 | ||
@@ -1921,7 +1925,7 @@ domain-browser@^1.1.1: | |||
1921 | version "1.1.7" | 1925 | version "1.1.7" |
1922 | resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" | 1926 | resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.1.7.tgz#867aa4b093faa05f1de08c06f4d7b21fdf8698bc" |
1923 | 1927 | ||
1924 | domelementtype@1: | 1928 | domelementtype@1, domelementtype@^1.3.0: |
1925 | version "1.3.0" | 1929 | version "1.3.0" |
1926 | resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" | 1930 | resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" |
1927 | 1931 | ||
@@ -1935,6 +1939,12 @@ domhandler@2.1: | |||
1935 | dependencies: | 1939 | dependencies: |
1936 | domelementtype "1" | 1940 | domelementtype "1" |
1937 | 1941 | ||
1942 | domhandler@^2.3.0: | ||
1943 | version "2.4.1" | ||
1944 | resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.1.tgz#892e47000a99be55bbf3774ffea0561d8879c259" | ||
1945 | dependencies: | ||
1946 | domelementtype "1" | ||
1947 | |||
1938 | domutils@1.1: | 1948 | domutils@1.1: |
1939 | version "1.1.6" | 1949 | version "1.1.6" |
1940 | resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.1.6.tgz#bddc3de099b9a2efacc51c623f28f416ecc57485" | 1950 | resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.1.6.tgz#bddc3de099b9a2efacc51c623f28f416ecc57485" |
@@ -1948,6 +1958,13 @@ domutils@1.5.1: | |||
1948 | dom-serializer "0" | 1958 | dom-serializer "0" |
1949 | domelementtype "1" | 1959 | domelementtype "1" |
1950 | 1960 | ||
1961 | domutils@^1.5.1: | ||
1962 | version "1.6.2" | ||
1963 | resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.6.2.tgz#1958cc0b4c9426e9ed367fb1c8e854891b0fa3ff" | ||
1964 | dependencies: | ||
1965 | dom-serializer "0" | ||
1966 | domelementtype "1" | ||
1967 | |||
1951 | duplexer@^0.1.1: | 1968 | duplexer@^0.1.1: |
1952 | version "0.1.1" | 1969 | version "0.1.1" |
1953 | resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" | 1970 | resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" |
@@ -2027,7 +2044,7 @@ enhanced-resolve@^3.1.0, enhanced-resolve@^3.4.0: | |||
2027 | object-assign "^4.0.1" | 2044 | object-assign "^4.0.1" |
2028 | tapable "^0.2.7" | 2045 | tapable "^0.2.7" |
2029 | 2046 | ||
2030 | entities@~1.1.1: | 2047 | entities@^1.1.1, entities@~1.1.1: |
2031 | version "1.1.1" | 2048 | version "1.1.1" |
2032 | resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" | 2049 | resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" |
2033 | 2050 | ||
@@ -3077,6 +3094,17 @@ html-webpack-plugin@^2.19.0, html-webpack-plugin@^2.29.0: | |||
3077 | pretty-error "^2.0.2" | 3094 | pretty-error "^2.0.2" |
3078 | toposort "^1.0.0" | 3095 | toposort "^1.0.0" |
3079 | 3096 | ||
3097 | htmlparser2@^3.9.0: | ||
3098 | version "3.9.2" | ||
3099 | resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" | ||
3100 | dependencies: | ||
3101 | domelementtype "^1.3.0" | ||
3102 | domhandler "^2.3.0" | ||
3103 | domutils "^1.5.1" | ||
3104 | entities "^1.1.1" | ||
3105 | inherits "^2.0.1" | ||
3106 | readable-stream "^2.0.2" | ||
3107 | |||
3080 | htmlparser2@~3.3.0: | 3108 | htmlparser2@~3.3.0: |
3081 | version "3.3.0" | 3109 | version "3.3.0" |
3082 | resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.3.0.tgz#cc70d05a59f6542e43f0e685c982e14c924a9efe" | 3110 | resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.3.0.tgz#cc70d05a59f6542e43f0e685c982e14c924a9efe" |
@@ -3917,6 +3945,10 @@ lodash.defaults@^4.0.0: | |||
3917 | version "4.2.0" | 3945 | version "4.2.0" |
3918 | resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" | 3946 | resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" |
3919 | 3947 | ||
3948 | lodash.escaperegexp@^4.1.2: | ||
3949 | version "4.1.2" | ||
3950 | resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" | ||
3951 | |||
3920 | lodash.isarguments@^3.0.0: | 3952 | lodash.isarguments@^3.0.0: |
3921 | version "3.1.0" | 3953 | version "3.1.0" |
3922 | resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" | 3954 | resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" |
@@ -5238,6 +5270,14 @@ postcss@^6.0.0, postcss@^6.0.1, postcss@^6.0.13: | |||
5238 | source-map "^0.6.1" | 5270 | source-map "^0.6.1" |
5239 | supports-color "^4.4.0" | 5271 | supports-color "^4.4.0" |
5240 | 5272 | ||
5273 | postcss@^6.0.14: | ||
5274 | version "6.0.15" | ||
5275 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.15.tgz#f460cd6269fede0d1bf6defff0b934a9845d974d" | ||
5276 | dependencies: | ||
5277 | chalk "^2.3.0" | ||
5278 | source-map "^0.6.1" | ||
5279 | supports-color "^5.1.0" | ||
5280 | |||
5241 | prebuild-install@~2.3.0: | 5281 | prebuild-install@~2.3.0: |
5242 | version "2.3.0" | 5282 | version "2.3.0" |
5243 | resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.3.0.tgz#19481247df728b854ab57b187ce234211311b485" | 5283 | resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-2.3.0.tgz#19481247df728b854ab57b187ce234211311b485" |
@@ -5891,6 +5931,18 @@ safe-json-parse@4.0.0: | |||
5891 | dependencies: | 5931 | dependencies: |
5892 | rust-result "^1.0.0" | 5932 | rust-result "^1.0.0" |
5893 | 5933 | ||
5934 | sanitize-html@^1.16.3: | ||
5935 | version "1.16.3" | ||
5936 | resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-1.16.3.tgz#96c1b44a36ff7312e1c22a14b05274370ac8bd56" | ||
5937 | dependencies: | ||
5938 | htmlparser2 "^3.9.0" | ||
5939 | lodash.clonedeep "^4.5.0" | ||
5940 | lodash.escaperegexp "^4.1.2" | ||
5941 | lodash.mergewith "^4.6.0" | ||
5942 | postcss "^6.0.14" | ||
5943 | srcset "^1.0.0" | ||
5944 | xtend "^4.0.0" | ||
5945 | |||
5894 | sass-graph@^2.2.4: | 5946 | sass-graph@^2.2.4: |
5895 | version "2.2.4" | 5947 | version "2.2.4" |
5896 | resolved "https://registry.yarnpkg.com/sass-graph/-/sass-graph-2.2.4.tgz#13fbd63cd1caf0908b9fd93476ad43a51d1e0b49" | 5948 | resolved "https://registry.yarnpkg.com/sass-graph/-/sass-graph-2.2.4.tgz#13fbd63cd1caf0908b9fd93476ad43a51d1e0b49" |
@@ -6335,6 +6387,13 @@ sprintf-js@~1.0.2: | |||
6335 | version "1.0.3" | 6387 | version "1.0.3" |
6336 | resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" | 6388 | resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" |
6337 | 6389 | ||
6390 | srcset@^1.0.0: | ||
6391 | version "1.0.0" | ||
6392 | resolved "https://registry.yarnpkg.com/srcset/-/srcset-1.0.0.tgz#a5669de12b42f3b1d5e83ed03c71046fc48f41ef" | ||
6393 | dependencies: | ||
6394 | array-uniq "^1.0.2" | ||
6395 | number-is-nan "^1.0.0" | ||
6396 | |||
6338 | sshpk@^1.7.0: | 6397 | sshpk@^1.7.0: |
6339 | version "1.13.1" | 6398 | version "1.13.1" |
6340 | resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" | 6399 | resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" |
@@ -6562,6 +6621,12 @@ supports-color@^4.0.0, supports-color@^4.2.1, supports-color@^4.4.0: | |||
6562 | dependencies: | 6621 | dependencies: |
6563 | has-flag "^2.0.0" | 6622 | has-flag "^2.0.0" |
6564 | 6623 | ||
6624 | supports-color@^5.1.0: | ||
6625 | version "5.1.0" | ||
6626 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.1.0.tgz#058a021d1b619f7ddf3980d712ea3590ce7de3d5" | ||
6627 | dependencies: | ||
6628 | has-flag "^2.0.0" | ||
6629 | |||
6565 | svgo@^0.7.0: | 6630 | svgo@^0.7.0: |
6566 | version "0.7.2" | 6631 | version "0.7.2" |
6567 | resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5" | 6632 | resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.2.tgz#9f5772413952135c6fefbf40afe6a4faa88b4bb5" |