aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-miniature/video-filters.model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-video-miniature/video-filters.model.ts')
-rw-r--r--client/src/app/shared/shared-video-miniature/video-filters.model.ts26
1 files changed, 18 insertions, 8 deletions
diff --git a/client/src/app/shared/shared-video-miniature/video-filters.model.ts b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
index 73a30ca08..4069ab4b5 100644
--- a/client/src/app/shared/shared-video-miniature/video-filters.model.ts
+++ b/client/src/app/shared/shared-video-miniature/video-filters.model.ts
@@ -1,7 +1,8 @@
1import { splitIntoArray, toBoolean } from '@app/helpers' 1import { splitIntoArray, toBoolean } from '@app/helpers'
2import { getAllPrivacies } from '@shared/core-utils' 2import { getAllPrivacies } from '@shared/core-utils'
3import { AttributesOnly } from '@shared/typescript-utils' 3import { escapeHTML } from '@shared/core-utils/renderer'
4import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models' 4import { BooleanBothQuery, NSFWPolicyType, VideoInclude, VideoPrivacy, VideoSortField } from '@shared/models'
5import { AttributesOnly } from '@shared/typescript-utils'
5 6
6type VideoFiltersKeys = { 7type VideoFiltersKeys = {
7 [ id in keyof AttributesOnly<VideoFilters> ]: any 8 [ id in keyof AttributesOnly<VideoFilters> ]: any
@@ -90,19 +91,28 @@ export class VideoFilters {
90 } 91 }
91 92
92 load (obj: Partial<AttributesOnly<VideoFilters>>) { 93 load (obj: Partial<AttributesOnly<VideoFilters>>) {
93 if (obj.sort !== undefined) this.sort = obj.sort 94 // FIXME: We may use <ng-option> that doesn't escape HTML so prefer to escape things
95 // https://github.com/ng-select/ng-select/issues/1363
96
97 const escapeIfNeeded = (value: any) => {
98 if (typeof value === 'string') return escapeHTML(value)
99
100 return value
101 }
102
103 if (obj.sort !== undefined) this.sort = escapeIfNeeded(obj.sort) as VideoSortField
94 104
95 if (obj.nsfw !== undefined) this.nsfw = obj.nsfw 105 if (obj.nsfw !== undefined) this.nsfw = escapeIfNeeded(obj.nsfw) as BooleanBothQuery
96 106
97 if (obj.languageOneOf !== undefined) this.languageOneOf = splitIntoArray(obj.languageOneOf) 107 if (obj.languageOneOf !== undefined) this.languageOneOf = splitIntoArray(escapeIfNeeded(obj.languageOneOf))
98 if (obj.categoryOneOf !== undefined) this.categoryOneOf = splitIntoArray(obj.categoryOneOf) 108 if (obj.categoryOneOf !== undefined) this.categoryOneOf = splitIntoArray(escapeIfNeeded(obj.categoryOneOf))
99 109
100 if (obj.scope !== undefined) this.scope = obj.scope 110 if (obj.scope !== undefined) this.scope = escapeIfNeeded(obj.scope) as VideoFilterScope
101 if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos) 111 if (obj.allVideos !== undefined) this.allVideos = toBoolean(obj.allVideos)
102 112
103 if (obj.live !== undefined) this.live = obj.live 113 if (obj.live !== undefined) this.live = escapeIfNeeded(obj.live) as BooleanBothQuery
104 114
105 if (obj.search !== undefined) this.search = obj.search 115 if (obj.search !== undefined) this.search = escapeIfNeeded(obj.search)
106 116
107 this.buildActiveFilters() 117 this.buildActiveFilters()
108 } 118 }