Ticket #527 (closed defect: fixed)

Opened 1 year ago

Last modified 11 months ago

Search extension's <r:truncate_and_strip> tag default limit doesn't work

Reported by: danielegozzi@weblab.ing.unimo.it Assigned to:
Priority: trivial Milestone:
Component: Keywords:
Cc:

Description

When rendering the contents of truncate_and_strip tag, the length of the output may be limited by the "limit" attribute, which is optional. Looking at the source, it seems that this limit should be 100 by default. However, (tag.attrlength?.to_i 100) evaluates as '0 ' when the length attribute is not specified, thus producing unlimited output.

Proposed patch:

diff -bu search_page.rb search_page_patched.rb
--- search_page.rb      2007-05-11 03:59:02.000000000 +0200
+++ search_page_patched.rb  2007-09-20 15:41:52.000000000 +0200
@@ -50,7 +50,8 @@
     Useful for displaying a snippet of a found page.  The optional `length' attribute
     specifies how many characters to truncate to.}
   tag 'truncate_and_strip' do |tag|
-    length = tag.attr["length"].to_i || 100
+    tag.attr["length"] ||= 100
+    length = tag.attr["length"].to_i
     helper = ActionView::Base.new
     helper.truncate(helper.strip_tags(tag.expand).gsub(/\s+/," "), length)
   end

Change History

10/04/07 11:31:47 changed by seancribbs

  • status changed from new to closed.
  • resolution set to fixed.

Resolved in r531.