This repository was archived by the owner on May 14, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +14
-24
lines changed Expand file tree Collapse file tree 3 files changed +14
-24
lines changed Original file line number Diff line number Diff line change @@ -171,9 +171,21 @@ function cloneFilter(input) {
171
171
}
172
172
}
173
173
174
+ function escapedToHex ( str ) {
175
+ return str . replace ( / \\ ( [ 0 - 9 a - f ] [ ^ 0 - 9 a - f ] | [ 0 - 9 a - f ] $ | [ ^ 0 - 9 a - f ] | $ ) / gi, function ( match , p1 ) {
176
+ if ( ! p1 ) {
177
+ return '\\5c' ;
178
+ }
179
+
180
+ const hexCode = p1 . charCodeAt ( 0 ) . toString ( 16 ) ;
181
+ const rest = p1 . substring ( 1 ) ;
182
+ return '\\' + hexCode + rest ;
183
+ } ) ;
184
+ }
174
185
175
186
function parseString ( str ) {
176
- var generic = parents . parse ( str ) ;
187
+ const hexStr = escapedToHex ( str ) ;
188
+ const generic = parents . parse ( hexStr ) ;
177
189
// The filter object(s) return from ldap-filter.parse lack the toBer/parse
178
190
// decoration that native ldapjs filter possess. cloneFilter adds that back.
179
191
return cloneFilter ( generic ) ;
Original file line number Diff line number Diff line change 33
33
"asn1" : " 0.2.3" ,
34
34
"assert-plus" : " ^1.0.0" ,
35
35
"backoff" : " ^2.5.0" ,
36
- "ldap-filter" : " ^0.2.2 " ,
36
+ "ldap-filter" : " ^0.3.3 " ,
37
37
"dashdash" : " ^1.14.0" ,
38
38
"once" : " ^1.4.0" ,
39
39
"vasync" : " ^1.6.4" ,
Original file line number Diff line number Diff line change @@ -52,28 +52,6 @@ test(') in filter', function (t) {
52
52
} ) ;
53
53
54
54
55
- test ( '( in filter' , function ( t ) {
56
- var str = 'foo(bar=baz\\()' ;
57
- var f = parse ( str ) ;
58
- t . ok ( f ) ;
59
- t . equal ( f . attribute , 'foo(bar' ) ;
60
- t . equal ( f . value , 'baz()' ) ;
61
- t . equal ( f . toString ( ) , '(foo\\28bar=baz\\28\\29)' ) ;
62
- t . end ( ) ;
63
- } ) ;
64
-
65
-
66
- test ( '( in filter' , function ( t ) {
67
- var str = 'foo)(&(bar=baz)(' ;
68
- var f = parse ( str ) ;
69
- t . ok ( f ) ;
70
- t . equal ( f . attribute , 'foo)(&(bar' ) ;
71
- t . equal ( f . value , 'baz)(' ) ;
72
- t . equal ( f . toString ( ) , '(foo\\29\\28&\\28bar=baz\\29\\28)' ) ;
73
- t . end ( ) ;
74
- } ) ;
75
-
76
-
77
55
test ( '\\ in filter' , function ( t ) {
78
56
var str = '(foo=bar\\\\)' ;
79
57
var f = parse ( str ) ;
You can’t perform that action at this time.
0 commit comments