]> source.dussan.org Git - redmine.git/commitdiff
Fixed: tokens not escaped in highlight_tokens regexp (#1702).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 28 Jul 2008 21:11:49 +0000 (21:11 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 28 Jul 2008 21:11:49 +0000 (21:11 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1709 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/search_helper.rb

index 92f2da8a5096fea8e29662ae2971404fdde00912..cd96dbd3f535ee13616fc28bfb2ee2269d97dab0 100644 (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