Skip to content

Commit 241d9b8

Browse files
author
blackhedd
committed
Took a suggestion from Andre Nathan (andre@digirati.com.br)
to change the behavior of Net::LDAP::Filter#method_missing to allow case-insensitive attribute names.
1 parent 7de0147 commit 241d9b8

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/net/ldap/entry.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LDAP
5050
# restrict the range of characters allowed in attribute names.
5151
# To simplify handling attribute names, Net::LDAP::Entry
5252
# internally converts them to a standard format. Therefore, the
53-
# methods which take attribute names can take Strings or Synmbols,
53+
# methods which take attribute names can take Strings or Symbols,
5454
# and work correctly regardless of case or capitalization.
5555
#
5656
# An attribute consists of zero or more data items called
@@ -140,7 +140,7 @@ def each
140140
# arguments or a block...
141141
#
142142
def method_missing *args, &block # :nodoc:
143-
s = args[0]
143+
s = args[0].to_s.downcase.intern
144144
if attribute_names.include?(s)
145145
self[s]
146146
elsif s.to_s[-1] == 61 and s.to_s.length > 1

lib/net/ldap/filter.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,14 @@ def match entry
272272

273273
# Converts an LDAP filter-string (in the prefix syntax specified in RFC-2254)
274274
# to a Net::LDAP::Filter.
275-
def self.from_rfc2254 str
276-
FilterParser.new(str).filter
275+
def self.construct ldap_filter_string
276+
FilterParser.new(ldap_filter_string).filter
277+
end
278+
279+
# Synonym for #construct.
280+
# to a Net::LDAP::Filter.
281+
def self.from_rfc2254 ldap_filter_string
282+
construct ldap_filter_string
277283
end
278284

279285
end # class Net::LDAP::Filter

0 commit comments

Comments
 (0)