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 +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright 2011 Mark Cavage, Inc. All rights reserved.
2
2
3
- var assert = require ( 'assert' ) ;
3
+ var assert = require ( 'assert-plus ' ) ;
4
4
var util = require ( 'util' ) ;
5
5
6
6
var ASN1 = require ( 'asn1' ) . Ber ;
@@ -20,6 +20,29 @@ Filter.mixin(EqualityFilter);
20
20
module . exports = EqualityFilter ;
21
21
22
22
23
+ EqualityFilter . prototype . matches = function ( target , strictAttrCase ) {
24
+ assert . object ( target , 'target' ) ;
25
+
26
+ var tv = parents . getAttrValue ( target , this . attribute , strictAttrCase ) ;
27
+ var value = this . value ;
28
+
29
+ if ( this . attribute . toLowerCase ( ) === 'objectclass' ) {
30
+ /*
31
+ * Perform case-insensitive match for objectClass since nearly every LDAP
32
+ * implementation behaves in this manner.
33
+ */
34
+ value = value . toLowerCase ( ) ;
35
+ return parents . testValues ( function ( v ) {
36
+ return value === v . toLowerCase ( ) ;
37
+ } , tv ) ;
38
+ } else {
39
+ return parents . testValues ( function ( v ) {
40
+ return value === v ;
41
+ } , tv ) ;
42
+ }
43
+ } ;
44
+
45
+
23
46
EqualityFilter . prototype . parse = function ( ber ) {
24
47
assert . ok ( ber ) ;
25
48
Original file line number Diff line number Diff line change @@ -182,3 +182,17 @@ test('handle values passed via buffer', function (t) {
182
182
}
183
183
t . end ( ) ;
184
184
} ) ;
185
+
186
+
187
+ test ( 'GH-277 objectClass should be case-insensitive' , function ( t ) {
188
+ var f = new EqualityFilter ( {
189
+ attribute : 'objectClass' ,
190
+ value : 'CaseInsensitiveObj'
191
+ } ) ;
192
+ t . ok ( f ) ;
193
+ t . ok ( f . matches ( { objectClass : 'CaseInsensitiveObj' } ) ) ;
194
+ t . ok ( f . matches ( { OBJECTCLASS : 'CASEINSENSITIVEOBJ' } ) ) ;
195
+ t . ok ( f . matches ( { objectclass : 'caseinsensitiveobj' } ) ) ;
196
+ t . ok ( ! f . matches ( { objectclass : 'matchless' } ) ) ;
197
+ t . end ( ) ;
198
+ } ) ;
You can’t perform that action at this time.
0 commit comments