File tree Expand file tree Collapse file tree 6 files changed +28
-18
lines changed Expand file tree Collapse file tree 6 files changed +28
-18
lines changed Original file line number Diff line number Diff line change 11import { useMemo } from "react" ;
22import DOMPurify from "dompurify" ;
33import type { TicketFieldObject } from "../ticket-fields/data-types/TicketFieldObject" ;
4+ import { ALLOWED_HTML_TAGS } from "../shared" ;
45
56const MAX_URL_LENGTH = 2048 ;
67const TICKET_FIELD_PREFIX = "tf_" ;
78const DATE_REGEX = / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / ;
89
910const ALLOWED_BOOLEAN_VALUES = [ "true" , "false" ] ;
10- const ALLOWED_HTML_TAGS = [
11- "pre" ,
12- "strong" ,
13- "b" ,
14- "p" ,
15- "blockquote" ,
16- "ul" ,
17- "ol" ,
18- "li" ,
19- "h2" ,
20- "h3" ,
21- "h4" ,
22- "i" ,
23- "em" ,
24- "br" ,
25- ] ;
2611
2712interface Fields {
2813 ticketFields : TicketFieldObject [ ] ;
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ import type { TicketFieldObject } from "../../ticket-fields/data-types/TicketFie
55import type { EndUserCondition } from "../../ticket-fields/data-types/EndUserCondition" ;
66import { getCustomObjectKey } from "../../ticket-fields/fields/LookupField" ;
77import { getVisibleFields } from "../../ticket-fields/getVisibleFields" ;
8+ import DOMPurify from "dompurify" ;
9+ import { ALLOWED_HTML_TAGS } from "../../shared" ;
810
911const getFieldValue = ( field : TicketField ) => {
1012 if ( field . type === "tagger" ) {
@@ -26,11 +28,16 @@ const formatField = (field: TicketField): TicketFieldObject => {
2628 relationship_target_type,
2729 relationship_filter,
2830 } = field ;
31+
32+ const sanitizedDescription = DOMPurify . sanitize ( description , {
33+ ALLOWED_TAGS : ALLOWED_HTML_TAGS ,
34+ } ) ;
35+
2936 return {
3037 id,
3138 type,
3239 name : `custom_fields_${ id } ` ,
33- description,
40+ description : sanitizedDescription ,
3441 label : title_in_portal ,
3542 options : custom_field_options ,
3643 required : required_in_portal ,
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from "./notifications";
22export * from "./i18n" ;
33export * from "./garden-theme" ;
44export * from "./error-boundary" ;
5+ export * from "./validations" ;
Original file line number Diff line number Diff line change 1+ export const ALLOWED_HTML_TAGS = [
2+ "pre" ,
3+ "strong" ,
4+ "b" ,
5+ "p" ,
6+ "blockquote" ,
7+ "ul" ,
8+ "ol" ,
9+ "li" ,
10+ "h2" ,
11+ "h3" ,
12+ "h4" ,
13+ "i" ,
14+ "em" ,
15+ "br" ,
16+ ] ;
Original file line number Diff line number Diff line change 1+ export * from "./constants" ;
Original file line number Diff line number Diff line change 2020 " service-catalog-translations" : " {{asset 'service-catalog-translations-bundle.js'}}" ,
2121 " shared" : " {{asset 'shared-bundle.js'}}" ,
2222 " ticket-fields" : " {{asset 'ticket-fields-bundle.js'}}" ,
23- " wysiwyg" : " {{asset 'wysiwyg-bundle.js'}}"
23+ " wysiwyg" : " {{asset 'wysiwyg-bundle.js'}}" ,
2424 }
2525}
2626</script >
You can’t perform that action at this time.
0 commit comments