@@ -54,11 +54,10 @@ sf.tags = [
54
54
{
55
55
"name" : "color" ,
56
56
"tag" : "color" ,
57
+ "sensitive" : true , // Prevent exploits
57
58
"src" : "https://raw.githubusercontent.com/Remix-Design/RemixIcon/master/icons/Design/paint-brush-line.svg" ,
58
59
"fillers" : [ "[color=red]" , "[/color]" ] ,
59
60
"formatter" : function ( part1 , part2 ) {
60
- part1 = part1 . replace ( / [ ^ a - z A - Z 0 - 9 \# \( \) \, ] / g, "" ) ; // Strip chars for security
61
- console . log ( part1 ) ;
62
61
return "<span style='color:" + part1 + "'>" + part2 + "</span>" ;
63
62
}
64
63
} ,
@@ -252,8 +251,8 @@ sf.parse = function(text) {
252
251
// Note that the new scratchformat standard is [],
253
252
// and the () is outdated, and a bit harder to type.
254
253
// But, we will detect both for historical reasons
255
- var startBracket = "[\\(|\\[]" ;
256
- var endBracket = "[\\)|\\]]" ;
254
+ let startBracket = "[\\(|\\[]" ;
255
+ let endBracket = "[\\)|\\]]" ;
257
256
258
257
for ( var t = 0 ; t < sf . tags . length ; t ++ ) {
259
258
if ( sf . tags [ t ] . ignore ) {
@@ -264,10 +263,15 @@ sf.parse = function(text) {
264
263
var regex = "" ;
265
264
regex += startBracket ;
266
265
regex += sf . tags [ t ] . tag ;
267
- regex += "[=]*([^\\]\\[\\)\\(]*)" ;
266
+ if ( sf . tags [ t ] . sensitive ) {
267
+ regex += "[=]*([a-zA-Z0-9\#\(\)\,]*)" ;
268
+ } else {
269
+ regex += "[=]*([^\\]\\[\\)\\(]*)" ;
270
+ }
271
+
268
272
regex += endBracket ;
269
273
270
- // If just 1 tag (Ex [br ])
274
+ // If just 1 tag (Ex [easteregg ])
271
275
if ( sf . tags [ t ] . fillers . length > 1 ) {
272
276
// Lazy matching (?)
273
277
// Since we can't use the s flag in Firefox,
0 commit comments