File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 24
24
return val . replace ( / ( [ ! " # $ % & ' ( ) * + , . \/ : ; < = > ? @ \[ \\ \] ^ ` { | } ~ ] ) / g, '\\$1' ) ;
25
25
} ;
26
26
27
+ function escapeHTML ( str ) {
28
+ return str . replace ( / & / g, "&" )
29
+ . replace ( / < / g, "<" )
30
+ . replace ( / > / g, ">" )
31
+ . replace ( / " / g, """ )
32
+ . replace ( / ' / g, "'" )
33
+ . replace ( / \/ / g, "/" ) ;
34
+ }
35
+
27
36
function randomId ( ) {
28
37
return Math . floor ( 0x100000000 + ( Math . random ( ) * 0xF00000000 ) ) . toString ( 16 ) ;
29
38
}
1558
1567
var footer = '' ;
1559
1568
if ( data . options === null || data . options . searching !== false ) {
1560
1569
footer = $ . map ( colnames , function ( x ) {
1561
- return '<th><input type="text" placeholder="' + x + '" /></th>' ;
1570
+ // placeholder needs to be escaped (and HTML tags are stripped off)
1571
+ return '<th><input type="text" placeholder="' +
1572
+ escapeHTML ( x . replace ( / ( < ( [ ^ > ] + ) > ) / ig, '' ) ) +
1573
+ '" /></th>' ;
1562
1574
} ) . join ( '' ) ;
1563
1575
footer = '<tfoot>' + footer + '</tfoot>' ;
1564
1576
}
You can’t perform that action at this time.
0 commit comments