1
1
import { ChallengeDomain as LegacyChallengeDomain } from "@topcoder-framework/domain-acl" ;
2
2
import { DomainHelper , PhaseFactRequest , PhaseFactResponse } from "@topcoder-framework/lib-common" ;
3
- import xss from "xss " ;
3
+ import { sanitize } from "../helpers/Sanitizer " ;
4
4
import CoreOperations from "../common/CoreOperations" ;
5
5
import { Value } from "../dal/models/nosql/parti_ql" ;
6
6
import IdGenerator from "../helpers/IdGenerator" ;
@@ -129,15 +129,15 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
129
129
}
130
130
131
131
public async create ( input : CreateChallengeInput , metadata : Metadata ) : Promise < Challenge > {
132
- input . name = xss ( input . name ) ;
132
+ input . name = sanitize ( input . name ) ;
133
133
134
134
// prettier-ignore
135
135
const handle = metadata ?. get ( "handle" ) . length > 0 ? metadata ?. get ( "handle" ) ?. [ 0 ] . toString ( ) : "tcwebservice" ;
136
136
137
137
if ( Array . isArray ( input . discussions ) ) {
138
138
for ( const discussion of input . discussions ) {
139
139
discussion . id = IdGenerator . generateUUID ( ) ;
140
- discussion . name = xss ( discussion . name . substring ( 0 , 100 ) ) ;
140
+ discussion . name = sanitize ( discussion . name . substring ( 0 , 100 ) ) ;
141
141
}
142
142
}
143
143
@@ -151,6 +151,7 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
151
151
152
152
// End Anti-Corruption Layer
153
153
154
+ // prettier-ignore
154
155
const challenge : Challenge = {
155
156
id : IdGenerator . generateUUID ( ) ,
156
157
created : now ,
@@ -177,8 +178,8 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
177
178
legacy,
178
179
phases,
179
180
legacyId : legacyChallengeId != null ? legacyChallengeId : undefined ,
180
- description : xss ( input . description ?? "" ) ,
181
- privateDescription : xss ( input . privateDescription ?? "" ) ,
181
+ description : sanitize ( input . description ?? "" , input . descriptionFormat ) ,
182
+ privateDescription : sanitize ( input . privateDescription ?? "" , input . descriptionFormat ) ,
182
183
metadata :
183
184
input . metadata . map ( ( m ) => {
184
185
let parsedValue = m . value ;
@@ -286,14 +287,14 @@ class ChallengeDomain extends CoreOperations<Challenge, CreateChallengeInput> {
286
287
scanCriteria ,
287
288
// prettier-ignore
288
289
{
289
- name : input . name != null ? xss ( input . name ) : undefined ,
290
+ name : input . name != null ? sanitize ( input . name ) : undefined ,
290
291
typeId : input . typeId != null ? input . typeId : undefined ,
291
292
trackId : input . trackId != null ? input . trackId : undefined ,
292
293
timelineTemplateId : input . timelineTemplateId != null ? input . timelineTemplateId : undefined ,
293
294
legacy : input . legacy != null ? input . legacy : undefined ,
294
295
billing : input . billing != null ? input . billing : undefined ,
295
- description : input . description != null ? xss ( input . description ) : undefined ,
296
- privateDescription : input . privateDescription != null ? xss ( input . privateDescription ) : undefined ,
296
+ description : input . description != null ? sanitize ( input . description , input . descriptionFormat ?? challenge . descriptionFormat ) : undefined ,
297
+ privateDescription : input . privateDescription != null ? sanitize ( input . privateDescription , input . descriptionFormat ?? challenge . descriptionFormat ) : undefined ,
297
298
descriptionFormat : input . descriptionFormat != null ? input . descriptionFormat : undefined ,
298
299
task : input . task != null ? input . task : undefined ,
299
300
winners : input . winnerUpdate != null ? input . winnerUpdate . winners : undefined ,
0 commit comments