Defect #20730 » fix-tokenization-for-phrases-with-non-ascii-characte.patch
| lib/redmine/search.rb | ||
|---|---|---|
|
# extract tokens from the question
|
||
|
# eg. hello "bye bye" => ["hello", "bye bye"]
|
||
|
@tokens = @question.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
|
||
|
@tokens = @question.scan(%r{((\s|^)"[^"]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}
|
||
|
# tokens must be at least 2 characters long
|
||
|
@tokens = @tokens.uniq.select {|w| w.length > 1 }
|
||
|
# no more than 5 tokens to search for
|
||
| test/unit/search_test.rb | ||
|---|---|---|
|
Redmine::Database.reset
|
||
|
end
|
||
|
def test_fetcher_should_handle_accents_in_phrases
|
||
|
f = Redmine::Search::Fetcher.new('No special chars "in a phrase"', User.anonymous, %w(issues), Project.all)
|
||
|
assert_equal ['No', 'special', 'chars', 'in a phrase'], f.tokens
|
||
|
f = Redmine::Search::Fetcher.new('Special chars "in a phrase Öö"', User.anonymous, %w(issues), Project.all)
|
||
|
assert_equal ['Special', 'chars', 'in a phrase Öö'], f.tokens
|
||
|
end
|
||
|
private
|
||
|
def remove_permission(role, permission)
|
||