Skip to content

Commit

Permalink
Prevent overwriting previously decoded tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Dec 1, 2022
1 parent 3c8a373 commit 980e0bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var token = '%[a-f0-9]{2}';
var singleMatcher = new RegExp(token, 'gi');
var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
var multiMatcher = new RegExp('(' + token + ')+', 'gi');

function decodeComponents(components, split) {
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const tests = {
'%C2%B5': 'µ',
'%C2%B5%': 'µ%',
'%%C2%B5%': '%µ%',

// This should actually return `%ea%baZ%ba`, but fixes a DOS attack for now
'%ea%ba%5a%ba': ''
'%ea%ba%5a%ba': '%ea%baZ%ba',
'%C3%5A%A5': '%C3Z%A5',
'%C3%5A%A5%AB': '%C3Z%A5%AB'
};

function macro(t, input, expected) {
Expand Down

0 comments on commit 980e0bf

Please sign in to comment.