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 +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-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\\a'
31
+ const f = parse ( str )
32
+ t . ok ( f )
33
+ t . equal ( f . attribute , 'foo' )
34
+ t . equal ( f . value , 'bar(abcdefghia' )
35
+ t . equal ( f . toString ( ) , '(foo=bar\\28abcdefghia)' )
36
+ t . end ( )
37
+ } )
38
+
29
39
test ( '( in filter' , function ( t ) {
30
40
const str = '(foo=bar\\()'
31
41
const f = parse ( str )
@@ -56,6 +66,16 @@ test('\\ in filter', function (t) {
56
66
t . end ( )
57
67
} )
58
68
69
+ test ( 'not escaped \\ at end of filter' , function ( t ) {
70
+ const str = 'foo=bar\\'
71
+ const f = parse ( str )
72
+ t . ok ( f )
73
+ t . equal ( f . attribute , 'foo' )
74
+ t . equal ( f . value , 'bar\\' )
75
+ t . equal ( f . toString ( ) , '(foo=bar\\5c)' )
76
+ t . end ( )
77
+ } )
78
+
59
79
test ( '* in equality filter' , function ( t ) {
60
80
const str = '(foo=bar\\*)'
61
81
const f = parse ( str )
You can’t perform that action at this time.
0 commit comments