Skip to content

Commit 646cdce

Browse files
author
Rory O'Connell
committed
Merge pull request #66 from satoryu/fix_filter_parser
Bug Fix: Fails to generate filter parser when given string includes multibyte chars.
2 parents f39daed + 4e88248 commit 646cdce

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-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]|\\[a-fA-F\d]{2})+/)
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# encoding: utf-8
2+
require 'spec_helper'
3+
4+
describe Net::LDAP::Filter::FilterParser do
5+
6+
describe "#parse" do
7+
context "Given ASCIIs as filter string" do
8+
let(:filter_string) { "(cn=name)" }
9+
specify "should generate filter object" do
10+
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
11+
end
12+
end
13+
context "Given string including multibyte chars as filter string" do
14+
let(:filter_string) { "(cn=名前)" }
15+
specify "should generate filter object" do
16+
expect(Net::LDAP::Filter::FilterParser.parse(filter_string)).to be_a Net::LDAP::Filter
17+
end
18+
end
19+
end
20+
end

0 commit comments

Comments
 (0)