4
4
import './publicpath.js' ;
5
5
6
6
import Vue from 'vue' ;
7
+ import { htmlEscape } from 'escape-goat' ;
7
8
import 'jquery.are-you-sure' ;
8
9
import './vendor/semanticdropdown.js' ;
9
10
@@ -25,10 +26,6 @@ import {svg, svgs} from './svg.js';
25
26
26
27
const { AppSubUrl, StaticUrlPrefix, csrf} = window . config ;
27
28
28
- function htmlEncode ( text ) {
29
- return jQuery ( '<div />' ) . text ( text ) . html ( ) ;
30
- }
31
-
32
29
let previewFileModes ;
33
30
const commentMDEditors = { } ;
34
31
@@ -528,12 +525,12 @@ function initCommentForm() {
528
525
switch ( input_id ) {
529
526
case '#milestone_id' :
530
527
$list . find ( '.selected' ) . html ( `<a class="item" href=${ $ ( this ) . data ( 'href' ) } >${
531
- htmlEncode ( $ ( this ) . text ( ) ) } </a>`) ;
528
+ htmlEscape ( $ ( this ) . text ( ) ) } </a>`) ;
532
529
break ;
533
530
case '#assignee_id' :
534
531
$list . find ( '.selected' ) . html ( `<a class="item" href=${ $ ( this ) . data ( 'href' ) } >` +
535
532
`<img class="ui avatar image" src=${ $ ( this ) . data ( 'avatar' ) } >${
536
- htmlEncode ( $ ( this ) . text ( ) ) } </a>`) ;
533
+ htmlEscape ( $ ( this ) . text ( ) ) } </a>`) ;
537
534
}
538
535
$ ( `.ui${ select_id } .list .no-select` ) . addClass ( 'hide' ) ;
539
536
$ ( input_id ) . val ( $ ( this ) . data ( 'id' ) ) ;
@@ -1944,7 +1941,7 @@ function searchUsers() {
1944
1941
$ . each ( response . data , ( _i , item ) => {
1945
1942
let title = item . login ;
1946
1943
if ( item . full_name && item . full_name . length > 0 ) {
1947
- title += ` (${ htmlEncode ( item . full_name ) } )` ;
1944
+ title += ` (${ htmlEscape ( item . full_name ) } )` ;
1948
1945
}
1949
1946
items . push ( {
1950
1947
title,
@@ -2220,7 +2217,7 @@ function initTemplateSearch() {
2220
2217
// Parse the response from the api to work with our dropdown
2221
2218
$ . each ( response . data , ( _r , repo ) => {
2222
2219
filteredResponse . results . push ( {
2223
- name : htmlEncode ( repo . full_name ) ,
2220
+ name : htmlEscape ( repo . full_name ) ,
2224
2221
value : repo . id
2225
2222
} ) ;
2226
2223
} ) ;
@@ -3500,8 +3497,8 @@ function initIssueList() {
3500
3497
return ;
3501
3498
}
3502
3499
filteredResponse . results . push ( {
3503
- name : `#${ issue . number } ${ htmlEncode ( issue . title )
3504
- } <div class="text small dont-break-out">${ htmlEncode ( issue . repository . full_name ) } </div>`,
3500
+ name : `#${ issue . number } ${ htmlEscape ( issue . title )
3501
+ } <div class="text small dont-break-out">${ htmlEscape ( issue . repository . full_name ) } </div>`,
3505
3502
value : issue . id
3506
3503
} ) ;
3507
3504
} ) ;
0 commit comments