Browse Source

Fixed that search results are escaped twice.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10185 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/2.1.0
Jean-Philippe Lang 11 years ago
parent
commit
8b12702ebe
2 changed files with 22 additions and 2 deletions
  1. 2
    2
      app/views/search/index.html.erb
  2. 20
    0
      test/functional/search_controller_test.rb

+ 2
- 2
app/views/search/index.html.erb View File

@@ -29,8 +29,8 @@
<h3><%= l(:label_result_plural) %> (<%= @results_by_type.values.sum %>)</h3>
<dl id="search-results">
<% @results.each do |e| %>
<dt class="<%= e.event_type %>"><%= 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 %></dt>
<dd><span class="description"><%= highlight_tokens(h(e.event_description), @tokens) %></span>
<dt class="<%= e.event_type %>"><%= 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 %></dt>
<dd><span class="description"><%= highlight_tokens(e.event_description, @tokens) %></span>
<span class="author"><%= format_time(e.event_datetime) %></span></dd>
<% end %>
</dl>

+ 20
- 0
test/functional/search_controller_test.rb View File

@@ -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 => '<subject> escaped_once', :description => '<description> escaped_once')
get :index, :q => 'escaped_once'
assert_response :success
assert_select '#search-results' do
assert_select 'dt.issue a', :text => /&lt;subject&gt;/
assert_select 'dd', :text => /&lt;description&gt;/
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

Loading…
Cancel
Save