From 12356c562837a6bbbf1d358c664776bcac180f52 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Thu, 29 Sep 2011 14:46:10 -0700 Subject: [PATCH] GH-20 case insensitive treatment of attribute names in a DN --- lib/dn.js | 4 ++-- tst/dn.test.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/dn.js b/lib/dn.js index c987ae4..c029d95 100644 --- a/lib/dn.js +++ b/lib/dn.js @@ -26,7 +26,7 @@ function RDN(obj) { if (obj) { Object.keys(obj).forEach(function(k) { - self[k] = obj[k]; + self[k.toLowerCase()] = obj[k]; }); } } @@ -66,7 +66,7 @@ function parse(name) { trim(); var value = parseAttrValue(); trim(); - rdn[attr] = value; + rdn[attr.toLowerCase()] = value; if (cur >= len || name[cur] !== '+') break; ++cur; diff --git a/tst/dn.test.js b/tst/dn.test.js index ccdf06e..4eb106d 100644 --- a/tst/dn.test.js +++ b/tst/dn.test.js @@ -123,3 +123,11 @@ test('empty DNs GH-16', function(t) { t.notOk(_dn2.childOf('')); t.end(); }); + + +test('case insensitive attribute names GH-20', function(t) { + var dn1 = dn.parse('CN=foo, dc=bar'); + t.ok(dn1.equals('cn=foo, dc=bar')); + t.ok(dn1.equals(dn.parse('cn=foo, DC=bar'))); + t.end(); +});