diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 19:37:13 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-09-05 19:37:13 +0000 |
commit | 8dcc041244822db6d994bc04dea94306216c4ee0 (patch) | |
tree | 10fba9adf860ba474109bc58ab78a4c4545e470d /app/helpers/search_helper.rb | |
parent | c27106d8595c4ce668ae95cff776be932a525a9e (diff) | |
download | redmine-8dcc041244822db6d994bc04dea94306216c4ee0.tar.gz redmine-8dcc041244822db6d994bc04dea94306216c4ee0.zip |
Issue notes are now included in search.
Fixed: search results too long when there are many matches.
Fixed: search results not escaped.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@705 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/search_helper.rb')
-rw-r--r-- | app/helpers/search_helper.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index bc408a305..676a7e8e3 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -21,7 +21,12 @@ module SearchHelper regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE result = '' text.split(regexp).each_with_index do |words, i| - result << (i.even? ? (words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', words, :class => 'highlight')) + if result.length > 1200 + # maximum length of the preview reached + result << '...' + break + end + result << (i.even? ? h(words.length > 100 ? "#{words[0..44]} ... #{words[-45..-1]}" : words) : content_tag('span', h(words), :class => 'highlight')) end result end |