1
0
mirror of https://github.com/meineerde/redmine.git synced 2025-12-19 15:01:14 +00:00

Fix tokenization of phrases with non-ascii chars (#20730).

Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@14662 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2015-10-09 07:35:48 +00:00
parent 85866cdcf3
commit 3a3fe668c7
2 changed files with 9 additions and 1 deletions

View File

@ -58,7 +58,7 @@ module Redmine
# 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

View File

@ -190,6 +190,14 @@ class SearchTest < ActiveSupport::TestCase
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)