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 | |
parent | c3badc81fe3d78601fb278a7f28eeed63060d300 (diff) | |
download | PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.tar.gz PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.tar.zst PeerTube-2890b615f31ab7d519d8be66b49ff8712df90c51.zip |
Handle HTML is comments
-rw-r--r-- | client/package.json | 2 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment.component.html | 2 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment.component.scss | 8 | ||||
-rw-r--r-- | client/src/app/videos/+video-watch/comment/video-comment.component.ts | 13 | ||||
-rw-r--r-- | client/yarn.lock | 71 | ||||
-rw-r--r-- | config/test.yaml | 2 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | server/helpers/custom-validators/activitypub/video-comments.ts | 11 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-delete.ts | 7 | ||||
-rw-r--r-- | shared/models/activitypub/activity.ts | 2 | ||||
-rw-r--r-- | yarn.lock | 94 |
11 files changed, 100 insertions, 114 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" |
diff --git a/config/test.yaml b/config/test.yaml index feecb7883..379f15430 100644 --- a/config/test.yaml +++ b/config/test.yaml | |||
@@ -12,5 +12,5 @@ signup: | |||
12 | enabled: true | 12 | enabled: true |
13 | 13 | ||
14 | transcoding: | 14 | transcoding: |
15 | enabled: true | 15 | enabled: false |
16 | threads: 4 | 16 | threads: 4 |
diff --git a/package.json b/package.json index e082eeb6e..7b30d24fa 100644 --- a/package.json +++ b/package.json | |||
@@ -82,7 +82,6 @@ | |||
82 | "request": "^2.81.0", | 82 | "request": "^2.81.0", |
83 | "rimraf": "^2.5.4", | 83 | "rimraf": "^2.5.4", |
84 | "safe-buffer": "^5.0.1", | 84 | "safe-buffer": "^5.0.1", |
85 | "sanitize-html": "^1.16.3", | ||
86 | "scripty": "^1.5.0", | 85 | "scripty": "^1.5.0", |
87 | "sequelize": "4.25.2", | 86 | "sequelize": "4.25.2", |
88 | "sequelize-typescript": "^0.6.1", | 87 | "sequelize-typescript": "^0.6.1", |
@@ -112,7 +111,6 @@ | |||
112 | "@types/node": "^8.0.3", | 111 | "@types/node": "^8.0.3", |
113 | "@types/pem": "^1.9.3", | 112 | "@types/pem": "^1.9.3", |
114 | "@types/request": "^2.0.3", | 113 | "@types/request": "^2.0.3", |
115 | "@types/sanitize-html": "^1.14.0", | ||
116 | "@types/sequelize": "^4.0.55", | 114 | "@types/sequelize": "^4.0.55", |
117 | "@types/sharp": "^0.17.6", | 115 | "@types/sharp": "^0.17.6", |
118 | "@types/supertest": "^2.0.3", | 116 | "@types/supertest": "^2.0.3", |
diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/helpers/custom-validators/activitypub/video-comments.ts index 6928aced3..ce1209035 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/helpers/custom-validators/activitypub/video-comments.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import * as validator from 'validator' | 1 | import * as validator from 'validator' |
2 | import { exists, isDateValid } from '../misc' | 2 | import { exists, isDateValid } from '../misc' |
3 | import { isActivityPubUrlValid, isBaseActivityValid } from './misc' | 3 | import { isActivityPubUrlValid, isBaseActivityValid } from './misc' |
4 | import * as sanitizeHtml from 'sanitize-html' | ||
5 | 4 | ||
6 | function isVideoCommentCreateActivityValid (activity: any) { | 5 | function isVideoCommentCreateActivityValid (activity: any) { |
7 | return isBaseActivityValid(activity, 'Create') && | 6 | return isBaseActivityValid(activity, 'Create') && |
@@ -11,7 +10,6 @@ function isVideoCommentCreateActivityValid (activity: any) { | |||
11 | function isVideoCommentObjectValid (comment: any) { | 10 | function isVideoCommentObjectValid (comment: any) { |
12 | return comment.type === 'Note' && | 11 | return comment.type === 'Note' && |
13 | isActivityPubUrlValid(comment.id) && | 12 | isActivityPubUrlValid(comment.id) && |
14 | sanitizeCommentHTML(comment) && | ||
15 | isCommentContentValid(comment.content) && | 13 | isCommentContentValid(comment.content) && |
16 | isActivityPubUrlValid(comment.inReplyTo) && | 14 | isActivityPubUrlValid(comment.inReplyTo) && |
17 | isDateValid(comment.published) && | 15 | isDateValid(comment.published) && |
@@ -31,15 +29,6 @@ export { | |||
31 | 29 | ||
32 | // --------------------------------------------------------------------------- | 30 | // --------------------------------------------------------------------------- |
33 | 31 | ||
34 | function sanitizeCommentHTML (comment: any) { | ||
35 | return sanitizeHtml(comment.content, { | ||
36 | allowedTags: [ 'b', 'i', 'em', 'span', 'a' ], | ||
37 | allowedAttributes: { | ||
38 | 'a': [ 'href' ] | ||
39 | } | ||
40 | }) | ||
41 | } | ||
42 | |||
43 | function isCommentContentValid (content: any) { | 32 | function isCommentContentValid (content: any) { |
44 | return exists(content) && validator.isLength('' + content, { min: 1 }) | 33 | return exists(content) && validator.isLength('' + content, { min: 1 }) |
45 | } | 34 | } |
diff --git a/server/lib/activitypub/process/process-delete.ts b/server/lib/activitypub/process/process-delete.ts index 01751422d..07e6a0075 100644 --- a/server/lib/activitypub/process/process-delete.ts +++ b/server/lib/activitypub/process/process-delete.ts | |||
@@ -11,8 +11,9 @@ import { getOrCreateActorAndServerAndModel } from '../actor' | |||
11 | 11 | ||
12 | async function processDeleteActivity (activity: ActivityDelete) { | 12 | async function processDeleteActivity (activity: ActivityDelete) { |
13 | const actor = await getOrCreateActorAndServerAndModel(activity.actor) | 13 | const actor = await getOrCreateActorAndServerAndModel(activity.actor) |
14 | const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id | ||
14 | 15 | ||
15 | if (actor.url === activity.object) { | 16 | if (actor.url === objectUrl) { |
16 | if (actor.type === 'Person') { | 17 | if (actor.type === 'Person') { |
17 | if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.') | 18 | if (!actor.Account) throw new Error('Actor ' + actor.url + ' is a person but we cannot find it in database.') |
18 | 19 | ||
@@ -25,14 +26,14 @@ async function processDeleteActivity (activity: ActivityDelete) { | |||
25 | } | 26 | } |
26 | 27 | ||
27 | { | 28 | { |
28 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(activity.object) | 29 | const videoCommentInstance = await VideoCommentModel.loadByUrlAndPopulateAccount(objectUrl) |
29 | if (videoCommentInstance) { | 30 | if (videoCommentInstance) { |
30 | return processDeleteVideoComment(actor, videoCommentInstance) | 31 | return processDeleteVideoComment(actor, videoCommentInstance) |
31 | } | 32 | } |
32 | } | 33 | } |
33 | 34 | ||
34 | { | 35 | { |
35 | const videoInstance = await VideoModel.loadByUrlAndPopulateAccount(activity.object) | 36 | const videoInstance = await VideoModel.loadByUrlAndPopulateAccount(objectUrl) |
36 | if (videoInstance) { | 37 | if (videoInstance) { |
37 | return processDeleteVideo(actor, videoInstance) | 38 | return processDeleteVideo(actor, videoInstance) |
38 | } | 39 | } |
diff --git a/shared/models/activitypub/activity.ts b/shared/models/activitypub/activity.ts index 56f7103bf..8cede49a0 100644 --- a/shared/models/activitypub/activity.ts +++ b/shared/models/activitypub/activity.ts | |||
@@ -39,7 +39,7 @@ export interface ActivityUpdate extends BaseActivity { | |||
39 | 39 | ||
40 | export interface ActivityDelete extends BaseActivity { | 40 | export interface ActivityDelete extends BaseActivity { |
41 | type: 'Delete' | 41 | type: 'Delete' |
42 | object: string | 42 | object: string | { id: string } |
43 | } | 43 | } |
44 | 44 | ||
45 | export interface ActivityFollow extends BaseActivity { | 45 | export interface ActivityFollow extends BaseActivity { |
@@ -150,10 +150,6 @@ | |||
150 | "@types/form-data" "*" | 150 | "@types/form-data" "*" |
151 | "@types/node" "*" | 151 | "@types/node" "*" |
152 | 152 | ||
153 | "@types/sanitize-html@^1.14.0": | ||
154 | version "1.14.0" | ||
155 | resolved "https://registry.yarnpkg.com/@types/sanitize-html/-/sanitize-html-1.14.0.tgz#9a03ec58306e24feaa3fbdb8ab593934d53ecb05" | ||
156 | |||
157 | "@types/sequelize@4.0.79", "@types/sequelize@^4.0.55": | 153 | "@types/sequelize@4.0.79", "@types/sequelize@^4.0.55": |
158 | version "4.0.79" | 154 | version "4.0.79" |
159 | resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.0.79.tgz#74c366407a978e493e70d7cea3d80c681aed15c0" | 155 | resolved "https://registry.yarnpkg.com/@types/sequelize/-/sequelize-4.0.79.tgz#74c366407a978e493e70d7cea3d80c681aed15c0" |
@@ -352,7 +348,7 @@ array-union@^1.0.1: | |||
352 | dependencies: | 348 | dependencies: |
353 | array-uniq "^1.0.1" | 349 | array-uniq "^1.0.1" |
354 | 350 | ||
355 | array-uniq@^1.0.1, array-uniq@^1.0.2: | 351 | array-uniq@^1.0.1: |
356 | version "1.0.3" | 352 | version "1.0.3" |
357 | resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" | 353 | resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" |
358 | 354 | ||
@@ -802,7 +798,7 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: | |||
802 | strip-ansi "^3.0.0" | 798 | strip-ansi "^3.0.0" |
803 | supports-color "^2.0.0" | 799 | supports-color "^2.0.0" |
804 | 800 | ||
805 | chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0: | 801 | chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: |
806 | version "2.3.0" | 802 | version "2.3.0" |
807 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" | 803 | resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" |
808 | dependencies: | 804 | dependencies: |
@@ -1240,34 +1236,6 @@ doctrine@^2.0.0: | |||
1240 | dependencies: | 1236 | dependencies: |
1241 | esutils "^2.0.2" | 1237 | esutils "^2.0.2" |
1242 | 1238 | ||
1243 | dom-serializer@0: | ||
1244 | version "0.1.0" | ||
1245 | resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.0.tgz#073c697546ce0780ce23be4a28e293e40bc30c82" | ||
1246 | dependencies: | ||
1247 | domelementtype "~1.1.1" | ||
1248 | entities "~1.1.1" | ||
1249 | |||
1250 | domelementtype@1, domelementtype@^1.3.0: | ||
1251 | version "1.3.0" | ||
1252 | resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.0.tgz#b17aed82e8ab59e52dd9c19b1756e0fc187204c2" | ||
1253 | |||
1254 | domelementtype@~1.1.1: | ||
1255 | version "1.1.3" | ||
1256 | resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.1.3.tgz#bd28773e2642881aec51544924299c5cd822185b" | ||
1257 | |||
1258 | domhandler@^2.3.0: | ||
1259 | version "2.4.1" | ||
1260 | resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.1.tgz#892e47000a99be55bbf3774ffea0561d8879c259" | ||
1261 | dependencies: | ||
1262 | domelementtype "1" | ||
1263 | |||
1264 | domutils@^1.5.1: | ||
1265 | version "1.6.2" | ||
1266 | resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.6.2.tgz#1958cc0b4c9426e9ed367fb1c8e854891b0fa3ff" | ||
1267 | dependencies: | ||
1268 | dom-serializer "0" | ||
1269 | domelementtype "1" | ||
1270 | |||
1271 | dot-prop@^4.1.0: | 1239 | dot-prop@^4.1.0: |
1272 | version "4.2.0" | 1240 | version "4.2.0" |
1273 | resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" | 1241 | resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.0.tgz#1f19e0c2e1aa0e32797c49799f2837ac6af69c57" |
@@ -1322,10 +1290,6 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: | |||
1322 | dependencies: | 1290 | dependencies: |
1323 | once "^1.4.0" | 1291 | once "^1.4.0" |
1324 | 1292 | ||
1325 | entities@^1.1.1, entities@~1.1.1: | ||
1326 | version "1.1.1" | ||
1327 | resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" | ||
1328 | |||
1329 | error-ex@^1.2.0: | 1293 | error-ex@^1.2.0: |
1330 | version "1.3.1" | 1294 | version "1.3.1" |
1331 | resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" | 1295 | resolved "https://registry.yarnpkg.com/error-ex/-/error-ex-1.3.1.tgz#f855a86ce61adc4e8621c3cda21e7a7612c3a8dc" |
@@ -2125,17 +2089,6 @@ homedir-polyfill@^1.0.1: | |||
2125 | dependencies: | 2089 | dependencies: |
2126 | parse-passwd "^1.0.0" | 2090 | parse-passwd "^1.0.0" |
2127 | 2091 | ||
2128 | htmlparser2@^3.9.0: | ||
2129 | version "3.9.2" | ||
2130 | resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.9.2.tgz#1bdf87acca0f3f9e53fa4fcceb0f4b4cbb00b338" | ||
2131 | dependencies: | ||
2132 | domelementtype "^1.3.0" | ||
2133 | domhandler "^2.3.0" | ||
2134 | domutils "^1.5.1" | ||
2135 | entities "^1.1.1" | ||
2136 | inherits "^2.0.1" | ||
2137 | readable-stream "^2.0.2" | ||
2138 | |||
2139 | http-errors@1.6.2, http-errors@~1.6.2: | 2092 | http-errors@1.6.2, http-errors@~1.6.2: |
2140 | version "1.6.2" | 2093 | version "1.6.2" |
2141 | resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" | 2094 | resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" |
@@ -2669,10 +2622,6 @@ lodash.assign@^3.0.0: | |||
2669 | lodash._createassigner "^3.0.0" | 2622 | lodash._createassigner "^3.0.0" |
2670 | lodash.keys "^3.0.0" | 2623 | lodash.keys "^3.0.0" |
2671 | 2624 | ||
2672 | lodash.clonedeep@^4.5.0: | ||
2673 | version "4.5.0" | ||
2674 | resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef" | ||
2675 | |||
2676 | lodash.cond@^4.3.0: | 2625 | lodash.cond@^4.3.0: |
2677 | version "4.5.2" | 2626 | version "4.5.2" |
2678 | resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" | 2627 | resolved "https://registry.yarnpkg.com/lodash.cond/-/lodash.cond-4.5.2.tgz#f471a1da486be60f6ab955d17115523dd1d255d5" |
@@ -2684,10 +2633,6 @@ lodash.defaults@^3.1.2: | |||
2684 | lodash.assign "^3.0.0" | 2633 | lodash.assign "^3.0.0" |
2685 | lodash.restparam "^3.0.0" | 2634 | lodash.restparam "^3.0.0" |
2686 | 2635 | ||
2687 | lodash.escaperegexp@^4.1.2: | ||
2688 | version "4.1.2" | ||
2689 | resolved "https://registry.yarnpkg.com/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz#64762c48618082518ac3df4ccf5d5886dae20347" | ||
2690 | |||
2691 | lodash.isarguments@^3.0.0: | 2636 | lodash.isarguments@^3.0.0: |
2692 | version "3.1.0" | 2637 | version "3.1.0" |
2693 | resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" | 2638 | resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" |
@@ -2704,10 +2649,6 @@ lodash.keys@^3.0.0: | |||
2704 | lodash.isarguments "^3.0.0" | 2649 | lodash.isarguments "^3.0.0" |
2705 | lodash.isarray "^3.0.0" | 2650 | lodash.isarray "^3.0.0" |
2706 | 2651 | ||
2707 | lodash.mergewith@^4.6.0: | ||
2708 | version "4.6.0" | ||
2709 | resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55" | ||
2710 | |||
2711 | lodash.restparam@^3.0.0: | 2652 | lodash.restparam@^3.0.0: |
2712 | version "3.6.1" | 2653 | version "3.6.1" |
2713 | resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" | 2654 | resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" |
@@ -3416,14 +3357,6 @@ pluralize@^1.2.1: | |||
3416 | version "1.2.1" | 3357 | version "1.2.1" |
3417 | resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" | 3358 | resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" |
3418 | 3359 | ||
3419 | postcss@^6.0.14: | ||
3420 | version "6.0.14" | ||
3421 | resolved "https://registry.yarnpkg.com/postcss/-/postcss-6.0.14.tgz#5534c72114739e75d0afcf017db853099f562885" | ||
3422 | dependencies: | ||
3423 | chalk "^2.3.0" | ||
3424 | source-map "^0.6.1" | ||
3425 | supports-color "^4.4.0" | ||
3426 | |||
3427 | postgres-array@~1.0.0: | 3360 | postgres-array@~1.0.0: |
3428 | version "1.0.2" | 3361 | version "1.0.2" |
3429 | resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-1.0.2.tgz#8e0b32eb03bf77a5c0a7851e0441c169a256a238" | 3362 | resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-1.0.2.tgz#8e0b32eb03bf77a5c0a7851e0441c169a256a238" |
@@ -3808,18 +3741,6 @@ safe-buffer@5.1.1, safe-buffer@^5.0.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, s | |||
3808 | version "5.1.1" | 3741 | version "5.1.1" |
3809 | resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" | 3742 | resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" |
3810 | 3743 | ||
3811 | sanitize-html@^1.16.3: | ||
3812 | version "1.16.3" | ||
3813 | resolved "https://registry.yarnpkg.com/sanitize-html/-/sanitize-html-1.16.3.tgz#96c1b44a36ff7312e1c22a14b05274370ac8bd56" | ||
3814 | dependencies: | ||
3815 | htmlparser2 "^3.9.0" | ||
3816 | lodash.clonedeep "^4.5.0" | ||
3817 | lodash.escaperegexp "^4.1.2" | ||
3818 | lodash.mergewith "^4.6.0" | ||
3819 | postcss "^6.0.14" | ||
3820 | srcset "^1.0.0" | ||
3821 | xtend "^4.0.0" | ||
3822 | |||
3823 | scripty@^1.5.0: | 3744 | scripty@^1.5.0: |
3824 | version "1.7.2" | 3745 | version "1.7.2" |
3825 | resolved "https://registry.yarnpkg.com/scripty/-/scripty-1.7.2.tgz#92367b724cb77b086729691f7b01aa57f3ddd356" | 3746 | resolved "https://registry.yarnpkg.com/scripty/-/scripty-1.7.2.tgz#92367b724cb77b086729691f7b01aa57f3ddd356" |
@@ -4045,7 +3966,7 @@ source-map@^0.5.6: | |||
4045 | version "0.5.7" | 3966 | version "0.5.7" |
4046 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" | 3967 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" |
4047 | 3968 | ||
4048 | source-map@^0.6.0, source-map@^0.6.1: | 3969 | source-map@^0.6.0: |
4049 | version "0.6.1" | 3970 | version "0.6.1" |
4050 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" | 3971 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" |
4051 | 3972 | ||
@@ -4073,13 +3994,6 @@ sprintf-js@~1.0.2: | |||
4073 | version "1.0.3" | 3994 | version "1.0.3" |
4074 | resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" | 3995 | resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" |
4075 | 3996 | ||
4076 | srcset@^1.0.0: | ||
4077 | version "1.0.0" | ||
4078 | resolved "https://registry.yarnpkg.com/srcset/-/srcset-1.0.0.tgz#a5669de12b42f3b1d5e83ed03c71046fc48f41ef" | ||
4079 | dependencies: | ||
4080 | array-uniq "^1.0.2" | ||
4081 | number-is-nan "^1.0.0" | ||
4082 | |||
4083 | sshpk@^1.7.0: | 3997 | sshpk@^1.7.0: |
4084 | version "1.13.1" | 3998 | version "1.13.1" |
4085 | resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" | 3999 | resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.1.tgz#512df6da6287144316dc4c18fe1cf1d940739be3" |
@@ -4265,7 +4179,7 @@ supports-color@^3.2.3: | |||
4265 | dependencies: | 4179 | dependencies: |
4266 | has-flag "^1.0.0" | 4180 | has-flag "^1.0.0" |
4267 | 4181 | ||
4268 | supports-color@^4.0.0, supports-color@^4.4.0: | 4182 | supports-color@^4.0.0: |
4269 | version "4.5.0" | 4183 | version "4.5.0" |
4270 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" | 4184 | resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" |
4271 | dependencies: | 4185 | dependencies: |