From 8b12702ebef20e54987673d898f8d261a317db02 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 10 Aug 2012 16:22:26 +0000 Subject: [PATCH] Fixed that search results are escaped twice. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10185 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/search/index.html.erb | 4 ++-- test/functional/search_controller_test.rb | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/search/index.html.erb b/app/views/search/index.html.erb index bf3951263..d4d671aa9 100644 --- a/app/views/search/index.html.erb +++ b/app/views/search/index.html.erb @@ -29,8 +29,8 @@

<%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)

<% @results.each do |e| %> -
<%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(h(e.event_title), :length => 255), @tokens), e.event_url %>
-
<%= highlight_tokens(h(e.event_description), @tokens) %> +
<%= content_tag('span', h(e.project), :class => 'project') unless @project == e.project %> <%= link_to highlight_tokens(truncate(e.event_title, :length => 255), @tokens), e.event_url %>
+
<%= highlight_tokens(e.event_description, @tokens) %> <%= format_time(e.event_datetime) %>
<% end %>
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb index fc40ce2f0..9491750bb 100644 --- a/test/functional/search_controller_test.rb +++ b/test/functional/search_controller_test.rb @@ -199,4 +199,24 @@ class SearchControllerTest < ActionController::TestCase get :index, :id => 1, :q => '"good bye" hello "bye bye"' assert_equal ["good bye", "hello", "bye bye"], assigns(:tokens) end + + def test_results_should_be_escaped_once + assert Issue.find(1).update_attributes(:subject => ' escaped_once', :description => ' escaped_once') + get :index, :q => 'escaped_once' + assert_response :success + assert_select '#search-results' do + assert_select 'dt.issue a', :text => /<subject>/ + assert_select 'dd', :text => /<description>/ + end + end + + def test_keywords_should_be_highlighted + assert Issue.find(1).update_attributes(:subject => 'subject highlighted', :description => 'description highlighted') + get :index, :q => 'highlighted' + assert_response :success + assert_select '#search-results' do + assert_select 'dt.issue a span.highlight', :text => 'highlighted' + assert_select 'dd span.highlight', :text => 'highlighted' + end + end end -- 2.39.5