File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed
Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 1+ const antiXSS = ( str ) => {
2+ const replacements = [
3+ [ / & / g, '&' ] ,
4+ [ / < / g, '<' ] ,
5+ [ / > / g, '>' ] ,
6+ [ / " / g, '"' ]
7+ ]
8+ for ( const replacement of replacements ) {
9+ str = str . replace ( replacement [ 0 ] , replacement [ 1 ] )
10+ }
11+ return str
12+ }
13+ export { antiXSS }
Original file line number Diff line number Diff line change 11import $ from 'jquery'
2-
2+ import { antiXSS } from './../additional/tools.js'
33class TabList {
44 constructor ( game ) {
55 this . game = game
@@ -10,7 +10,7 @@ class TabList {
1010 let newHTML = ''
1111 if ( players !== undefined && JSON . stringify ( players ) !== '{}' ) {
1212 for ( const i in players ) {
13- newHTML += `<div class="tab_player clearfix"><span class="float-left">${ i } </span><span class="float-right">${ players [ i ] . ping } ms</span></div>`
13+ newHTML += `<div class="tab_player clearfix"><span class="float-left">${ antiXSS ( i ) } </span><span class="float-right">${ players [ i ] . ping } ms</span></div>`
1414 }
1515 if ( newHTML !== this . lastHTML ) {
1616 this . lastHTML = newHTML
Original file line number Diff line number Diff line change 11/* eslint-env worker */
22import vec3 from 'vec3'
33import Convert from 'ansi-to-html'
4+ import { antiXSS } from './../additional/tools.js'
45const convert = new Convert ( )
56
67global . window = self
@@ -60,16 +61,7 @@ addEventListener('message', function (e) {
6061 emit ( 'kicked' , reason )
6162 } )
6263 bot . on ( 'message' , function ( msg ) {
63- let message = msg . toAnsi ( )
64-
65- const replacements = [
66- [ / & / g, '&' ] ,
67- [ / < / g, '<' ] ,
68- [ / > / g, '>' ] ,
69- [ / " / g, '"' ]
70- ]
71- for ( const replacement of replacements ) { message = message . replace ( replacement [ 0 ] , replacement [ 1 ] ) }
72-
64+ const message = antiXSS ( msg . toAnsi ( ) )
7365 emit ( 'msg' , convert . toHtml ( message ) )
7466 } )
7567 bot . on ( 'death' , ( ) => {
You can’t perform that action at this time.
0 commit comments