Skip to content

Commit bc45065

Browse files
author
Tatsuya Sato
committed
FilterParser can parse filter string including special chars.
1 parent d4a7355 commit bc45065

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/net/ldap/filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def parse_filter_branch(scanner)
755755
scanner.scan(/\s*/)
756756
if op = scanner.scan(/<=|>=|!=|:=|=/)
757757
scanner.scan(/\s*/)
758-
if value = scanner.scan(/(?:[-\w*.+@=,#\$%&!'\s\xC3\x80-\xCA\xAF]|[^\x00-\x7F]|\\[a-fA-F\d]{2})+/u)
758+
if value = scanner.scan(/(?:[-\[\]{}\w*.+@=,#\$%&!'^~\s\xC3\x80-\xCA\xAF]|[^\x00-\x7F]|\\[a-fA-F\d]{2})+/u)
759759
# 20100313 AZ: Assumes that "(uid=george*)" is the same as
760760
# "(uid=george* )". The standard doesn't specify, but I can find
761761
# no examples that suggest otherwise.

spec/unit/ldap/filter_parser_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66
describe "#parse" do
77
context "Given ASCIIs as filter string" do
88
let(:filter_string) { "(cn=name)" }
9+
910
specify "should generate filter object" do
1011
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
1112
end
1213
end
14+
1315
context "Given string including multibyte chars as filter string" do
1416
let(:filter_string) { "(cn=名前)" }
17+
18+
specify "should generate filter object" do
19+
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
20+
end
21+
end
22+
23+
context 'Given string including special chars allowd to be used in DN as filter string' do
24+
let(:filter_string) { '(cn=[{^something~}])' }
25+
1526
specify "should generate filter object" do
1627
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
1728
end

0 commit comments

Comments
 (0)