Patch #30037 » 30037-allow-single-chinese-character-search-keywords.diff
lib/redmine/search.rb (working copy) | ||
---|---|---|
60 | 60 |
# eg. hello "bye bye" => ["hello", "bye bye"] |
61 | 61 |
@tokens = @question.scan(%r{((\s|^)"[^"]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')} |
62 | 62 |
# tokens must be at least 2 characters long |
63 |
@tokens = @tokens.uniq.select {|w| w.length > 1 } |
|
63 |
# but for Chinese characters (汉字/漢字), tokens can be one character |
|
64 |
@tokens = @tokens.uniq.select {|w| (w.length > 1 || w =~ /\p{Han}/) } |
|
64 | 65 |
# no more than 5 tokens to search for |
65 | 66 |
@tokens.slice! 5..-1 |
66 | 67 |
end |
test/unit/search_test.rb (working copy) | ||
---|---|---|
194 | 194 |
assert_equal ['Special', 'chars', 'in a phrase Öö'], f.tokens |
195 | 195 |
end |
196 | 196 | |
197 |
def test_fetcher_should_ignore_too_short_tokens |
|
198 |
f = Redmine::Search::Fetcher.new('a bc á 漢 あ 한', User.anonymous, %w(issues), Project.all) |
|
199 |
assert_equal ['bc', '漢'], f.tokens |
|
200 |
end |
|
201 | ||
197 | 202 |
private |
198 | 203 | |
199 | 204 |
def remove_permission(role, permission) |
- « Previous
- 1
- 2
- Next »