Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #2229 (closed enhancement: fixed)

Opened 3 years ago

Last modified 2 years ago

[PATCH] Addition of strip_tags function to TextHelper

Reported by: marcin@junkheap.net Assigned to: David
Priority: normal Milestone:
Component: ActionPack Version: 0.13.1
Severity: normal Keywords:
Cc:

Description

Addition of a function called strip_tags to remove HTML tags from a text string. eg. "<p><a href="">foo</a> bar</p>" becomes "foo bar". Uses the html-scanner library as per sanitize for the HTML parsing, followed by a simple regexp for comment removal.

Attachments

text_helper_strip_tags.diff (2.2 kB) - added by marcin@junkheap.net on 09/19/05 06:18:03.
Patch file, including code and unit tests.
fix_parse_nil_to_strip_tags.diff (1.6 kB) - added by duncan@whomwah.com on 04/02/06 18:09:07.
Patch file attached, including tests that fixes strip_tags failing when passed nil or an empty string.

Change History

09/19/05 06:18:03 changed by marcin@junkheap.net

  • attachment text_helper_strip_tags.diff added.

Patch file, including code and unit tests.

10/26/05 13:26:08 changed by david

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

(In [2750]) Added TextHelper#strip_tags for removing HTML tags from a string (using HTMLTokenizer) (closes #2229) [marcin@junkheap.net]

02/20/06 02:32:32 changed by anonymous

how would i use the strip_tags function/feature to remote html tags before adding to database?

03/28/06 11:17:29 changed by duncan@whomwah.com

  • status changed from closed to reopened.
  • resolution deleted.

Should this function start with:

return nil if html.blank?

otherwise the function requires a conditional check before use?

04/02/06 18:09:07 changed by duncan@whomwah.com

  • attachment fix_parse_nil_to_strip_tags.diff added.

Patch file attached, including tests that fixes strip_tags failing when passed nil or an empty string.

09/03/06 16:47:05 changed by bitsweat

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

(In [4916]) strip_tags returns nil for a blank arg such as nil or "". Closes #2229.

11/26/06 01:00:11 changed by bitsweat

(In [5629]) strip_tags passes through blank args such as nil or "". Closes #6702, references #2229.