This repository was archived by the owner on May 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -165,14 +165,13 @@ function cloneFilter (input) {
165
165
}
166
166
167
167
function escapedToHex ( str ) {
168
- return str . replace ( / \\ ( [ 0 - 9 a - f ] [ ^ 0 - 9 a - f ] | [ 0 - 9 a - f ] $ | [ ^ 0 - 9 a - f ] | $ ) / gi, function ( match , p1 ) {
168
+ return str . replace ( / \\ ( [ 0 - 9 a - f ] (? ! [ 0 - 9 a - f ] ) | [ ^ 0 - 9 a - f ] | $ ) / gi, function ( match , p1 ) {
169
169
if ( ! p1 ) {
170
170
return '\\5c'
171
171
}
172
172
173
173
const hexCode = p1 . charCodeAt ( 0 ) . toString ( 16 )
174
- const rest = p1 . substring ( 1 )
175
- return '\\' + hexCode + rest
174
+ return '\\' + hexCode
176
175
} )
177
176
}
178
177
Original file line number Diff line number Diff line change @@ -26,6 +26,16 @@ test('GH-50 = in filter', function (t) {
26
26
t . end ( )
27
27
} )
28
28
29
+ test ( 'convert to hex code' , function ( t ) {
30
+ const str = 'foo=bar\\(abcd\\e\\fg\\h\\69\\'
31
+ const f = parse ( str )
32
+ t . ok ( f )
33
+ t . equal ( f . attribute , 'foo' )
34
+ t . equal ( f . value , 'bar(abcdefghi\\' )
35
+ t . equal ( f . toString ( ) , '(foo=bar\\28abcdefghi\\5c)' )
36
+ t . end ( )
37
+ } )
38
+
29
39
test ( '( in filter' , function ( t ) {
30
40
const str = '(foo=bar\\()'
31
41
const f = parse ( str )
You can’t perform that action at this time.
0 commit comments