Skip to content

Commit 980e0bf

Browse files
committedDec 1, 2022
Prevent overwriting previously decoded tokens
1 parent 3c8a373 commit 980e0bf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22
var token = '%[a-f0-9]{2}';
3-
var singleMatcher = new RegExp(token, 'gi');
3+
var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
44
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
55

66
function decodeComponents(components, split) {

‎test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const tests = {
3333
'%C2%B5': 'µ',
3434
'%C2%B5%': 'µ%',
3535
'%%C2%B5%': '%µ%',
36-
37-
// This should actually return `%ea%baZ%ba`, but fixes a DOS attack for now
38-
'%ea%ba%5a%ba': ''
36+
'%ea%ba%5a%ba': '%ea%baZ%ba',
37+
'%C3%5A%A5': '%C3Z%A5',
38+
'%C3%5A%A5%AB': '%C3Z%A5%AB'
3939
};
4040

4141
function macro(t, input, expected) {

0 commit comments

Comments
 (0)