File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var multiMatcher = new RegExp('(' + token + ')+', 'gi');
6
6
function decodeComponents ( components , split ) {
7
7
try {
8
8
// Try to decode the entire string first
9
- return decodeURIComponent ( components . join ( '' ) ) ;
9
+ return [ decodeURIComponent ( components . join ( '' ) ) ] ;
10
10
} catch ( err ) {
11
11
// Do nothing
12
12
}
@@ -28,12 +28,12 @@ function decode(input) {
28
28
try {
29
29
return decodeURIComponent ( input ) ;
30
30
} catch ( err ) {
31
- var tokens = input . match ( singleMatcher ) ;
31
+ var tokens = input . match ( singleMatcher ) || [ ] ;
32
32
33
33
for ( var i = 1 ; i < tokens . length ; i ++ ) {
34
34
input = decodeComponents ( tokens , i ) . join ( '' ) ;
35
35
36
- tokens = input . match ( singleMatcher ) ;
36
+ tokens = input . match ( singleMatcher ) || [ ] ;
37
37
}
38
38
39
39
return input ;
Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ const tests = {
32
32
'%C2x' : '\uFFFDx' ,
33
33
'%C2%B5' : 'µ' ,
34
34
'%C2%B5%' : 'µ%' ,
35
- '%%C2%B5%' : '%µ%'
35
+ '%%C2%B5%' : '%µ%' ,
36
+
37
+ // This should actually return `%ea%baZ%ba`, but fixes a DOS attack for now
38
+ '%ea%ba%5a%ba' : '꺺'
36
39
} ;
37
40
38
41
function macro ( t , input , expected ) {
You can’t perform that action at this time.
0 commit comments