Skip to content

Commit

Permalink
fix filter to parse various valid query character values properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jwedoff committed Nov 7, 2024
1 parent 1095f26 commit 822b70f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/net/ldap/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def parse_filter_branch(scanner)
scanner.scan(/\s*/)
if op = scanner.scan(/<=|>=|!=|:=|=/)
scanner.scan(/\s*/)
if value = scanner.scan(/(?:[-\[\]{}\w*.+\/:@=,#\$%&!'^~\s\xC3\x80-\xCA\xAF]|[^\x00-\x7F]|\\[a-fA-F\d]{2})+/u)
if value = scanner.scan(/(?:[-\[\]{}\w*.+\/:@=,#$%&!'^~;<>?"`|\s\xC3\x80-\xCA\xAF]|[^\x00-\x7F]|\\[a-fA-F\d]{2})+/u)
# 20100313 AZ: Assumes that "(uid=george*)" is the same as
# "(uid=george* )". The standard doesn't specify, but I can find
# no examples that suggest otherwise.
Expand Down
2 changes: 1 addition & 1 deletion lib/net/ldap/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Net
class LDAP
VERSION = "0.19.0.1.akajw"
VERSION = "0.19.0.2.akajw"
end
end
5 changes: 3 additions & 2 deletions net-ldap.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ the most recent LDAP RFCs (4510-4519, plutions of 4520-4532).}
s.require_paths = ["lib"]
s.required_ruby_version = ">= 2.0.0"
s.summary = %q{Net::LDAP for Ruby (also called net-ldap) implements client access for the Lightweight Directory Access Protocol (LDAP), an IETF standard protocol for accessing distributed directory services}

s.metadata["allowed_push_host"] = "https://geminabox.gcds.akamai.com"

s.add_development_dependency("flexmock", "~> 1.3")
s.add_development_dependency("rake", "~> 12.3.3")
s.add_development_dependency("rubocop", "~> 1.48")
s.add_development_dependency("test-unit", "~> 3.3")
s.add_development_dependency("byebug", "~> 9.0.6") unless RUBY_PLATFORM == "java"
s.add_development_dependency("byebug", "~> 11.1.3") unless RUBY_PLATFORM == "java"
end
24 changes: 24 additions & 0 deletions test/test_filter_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,28 @@ def test_colons
def test_attr_tag
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected])")
end

def test_semicolon_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected];bar)")
end

def test_gele_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected]<bar>)")
end

def test_question_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected]?bar)")
end

def test_backtick_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected]`bar)")
end

def test_pipe_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected]|bar)")
end

def test_dollar_value
assert_kind_of Net::LDAP::Filter, Net::LDAP::Filter::FilterParser.parse("(mail;[email protected]$bar)")
end
end

0 comments on commit 822b70f

Please sign in to comment.