Skip Menu |

This queue is for tickets about the CSS-Inliner CPAN distribution.

Report information
The Basics
Id: 59226
Status: resolved
Priority: 0/
Queue: CSS-Inliner

People
Owner: Nobody in particular
Requestors: wonko [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2544
Fixed in: (no value)



CSS::Inliner breaks if it encounters an HTML comment inside of the <style> blocks since it passes it off to HTML::Query as a CSS selector and that results in an error like: Invalid specification "<!-- .footer" in query: <!-- .footer It's pretty common to delineate <style> blocks with HTML comments so that older browsers don't have problems. It should be able to handle something like this: <style type="text/css"> <!-- .foo { color: blue } --> </style>
This attached patch fixes this issue.
Subject: handle_html_comments.patch
--- Inliner.pm.with_weight 2010-07-02 16:19:14.522172922 -0400 +++ Inliner.pm 2010-07-09 10:55:12.337139346 -0400 @@ -279,6 +279,10 @@ if (($i->tag eq 'style') && (!$i->attr('media') || $i->attr('media') =~ m/\b(all|screen)\b/)) { foreach my $item ($i->content_list()) { + # remove HTML comment markers + $item =~ s/<!--//mg; + $item =~ s/-->//mg; + $style .= $item; } $i->delete();
Hi Michael, I've merged this patch into the project verbatim. Look for it in the next release. thanks, Kevin