in reply to Pondering Portals
The modules available to filter HTML -- HTML::Scrubber, HTML::Sanitizer -- are missing what, to me, is a very important feature: enforcing tag balance. Those of us writing portal-style snippet-editing stuff often need to make sure that open tags match close tags, at the very least. Ideally, proper nesting would be enforced (and munged in by the filter itself).
Tag balance and proper nesting matter for two reasons: browsers often do odd, ugly and non-intuitive things to layout in the presence of unbalanced tags; and it is sometimes convenient to store snippets in x(ht)ml contexts, and forcing proper tag semantics on input removes the need to escape data in these kinds of systems. I have a hacked-up filter/balancer based on HTML::TreeBuilder. It works okay, is in the XML::Comma svn repository, and could be released with our next production version. But it would perhaps be nice to not impose yet-another-HTML-filter on the world, and to extend one of the existing offerings in this direction. So my question is, why don't other folks seem to care about this feature as much as we do -- what are we missing?
I do notice that perlmonks does some auto-balancing in posts (although not quite the same way I would). I did a bit of poking around at the Everything site, and it looks like the filter modules are not separate CPAN entities.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: sanitizing and balancing
by Tanktalus (Canon) on May 02, 2005 at 16:38 UTC |