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

Ticket #7641 (closed defect: fixed)

Opened 2 years ago

Last modified 1 year ago

[PATCH][TINY] Fix html-scanner parsing of empty tag pair

Reported by: anthony.bailey Assigned to: minam
Priority: normal Milestone: 1.x
Component: ActionPack Version: edge
Severity: normal Keywords:
Cc:

Description

When writing some page content regression tests, I noticed a distressing break in the round-trip from source to HTML::Document back to source. Here's the quick example:

>> HTML::Document.new("<tag></tag>").root.to_s
=> "<tag>"

HTML::Tag#to_s only outputs a closing tag if the tag has children. This could be changed, but would break such clients as ActionView::Helpers::TextHelper#sanitize which outputs tags one at a time as it tokenizes them. So my fix is instead to add an empty Text node to such Tag nodes when they are parsed in HTML::Document#initialize.

Attachments

html-scanner-parsing-empty-tag-pair.diff (1.8 kB) - added by anthony.bailey on 02/25/07 22:41:58.

Change History

02/25/07 22:41:58 changed by anthony.bailey

  • attachment html-scanner-parsing-empty-tag-pair.diff added.

05/12/07 01:48:29 changed by nzkoz

  • owner changed from core to minam.

Jamis is in charge of html-scanner

09/14/07 19:39:14 changed by anthony.bailey

  • summary changed from [PATCH] Fix html-scanner parsing of empty tag pair to [PATCH][TINY] Fix html-scanner parsing of empty tag pair.

Just noting that I sent Jamis Buick mail on 14 July:


Apologies for bothering you,

I'm informed you're responsible for the Rails copy of html-scanner down in actionpack/lib/action_controller/vendor/.

(Actually, I'm a little unclear as to the "vendor" status here - I couldn't locate the original project anywhere, or I would have raised this issue there. Please redirect me if appropriate!)

I'm writing re http://dev.rubyonrails.org/ticket/7641 which is a patch to fix a bug in parsing an empty tag pair.

Any thoughts on the ticket? It's been untouched for a while.


I didn't get anything back. That's OK, I'd much rather have Capistrano than my patch - but can somebody else look?

09/21/07 20:45:56 changed by nzkoz

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

(In [7528]) [html-scanner] Fix parsing of empty tags. Closes #7641. [anthony.bailey]