Browse Source

Fixed: tokens not escaped in highlight_tokens regexp (#1702).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1709 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/0.8.0-RC1
Jean-Philippe Lang 16 years ago
parent
commit
b91bdf8798
1 changed files with 2 additions and 1 deletions
  1. 2
    1
      app/helpers/search_helper.rb

+ 2
- 1
app/helpers/search_helper.rb View File

@@ -18,7 +18,8 @@
module SearchHelper
def highlight_tokens(text, tokens)
return text unless text && tokens && !tokens.empty?
regexp = Regexp.new "(#{tokens.join('|')})", Regexp::IGNORECASE
re_tokens = tokens.collect {|t| Regexp.escape(t)}
regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE
result = ''
text.split(regexp).each_with_index do |words, i|
if result.length > 1200

Loading…
Cancel
Save