<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>CSS?</title>
        <description>Hello,

Any means or plans to add the means for purifying CSS when injected into a stylesheet--i.e., when removing the &amp;lt;style&amp;gt; tags is not sufficient (i.e., removing javascript protocol from url(), etc.)?

thanks,
Brett

Edited 1 time(s). Last edit at 08/02/2007 11:13PM by Ambush Commander.</description>
        <link>http://htmlpurifier.org/phorum/read.php?2,551,551#msg-551</link>
        <lastBuildDate>Thu, 23 May 2013 18:57:28 -0400</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1356#msg-1356</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1356#msg-1356</link>
            <description><![CDATA[<blockquote>You meant CSSTidy doesn't also guarantee security, right? I take it you're referring to bogus image insertions, etc.? Can we do something about that?</blockquote>

<p>That, and more. CSSTidy doesn't guarantee standards-compliance with the CSS spec; HTML Purifier does. :-)</p>

<blockquote>Not sure what you mean by non-OOP. It does use classes and objects and the like... Do you mean it doesn't fully take advantage of OOP features? If so, which ones?</blockquote>

<p>OOP is not simply using classes and objects; it's a design philosophy. Consequently, the question what "features" aren't being used is a little nonsensical. Polymorphism is a biggy, though.</p>

<blockquote>No, this is not a pressing need. But some might prefer to work with a particular standard (and the rest of us in the world, (i.e., US, Liberia, and Myanmar) should already be using metric!)).</blockquote>

<p>True. But practically speaking, HTML Purifier's output is meant for output-only (and not re-editing by the person), so a conversion would introduce errors in scaling without any tangible benefit.</p>

<blockquote>To parse a style string, couldn't you just encapsulate the whole string in a dummy class selector or the like and then strip it?</blockquote>

<p>The problem with this approach is if the user passes something like <code>text-align:left;}more-css:properties;</code>. In theory, this is harmless in terms of security, but the user will end up loosing the rest the CSS string even though we should be able to keep it.</p>

<p>We've encountered this problem previously with HTMLPurifier_Lexer_DOMLex; this lexer operates by wrapping everything in HTML/BODY/DIV tags, so if a user has a stray closing div tag, the rest of the document <a href="http://htmlpurifier.org/demo.php?filter%5BCore.CollectErrors%5D=0&amp;filter%5BNull_URI.Munge%5D=1&amp;filter%5BURI.DisableExternalResources%5D=0&amp;filter%5BHTML.TidyLevel%5D=medium&amp;filter%5BHTML.Doctype%5D=&amp;filter%5BNull_HTML.Allowed%5D=1&amp;filter%5BCSS.Proprietary%5D=0&amp;filter%5BAutoFormat.AutoParagraph%5D=0&amp;filter%5BAutoFormat.Linkify%5D=0&amp;html=%3C%2Fdiv%3E%0D%0A%0D%0AThis+is+content+that+never+appears.&amp;submit=Submit">mysteriously disappears</a>.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Mon, 18 Feb 2008 22:58:31 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1355#msg-1355</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1355#msg-1355</link>
            <description><![CDATA[<p>Realized I hadn't responded to this way back...</p>

<blockquote cite="Ambush%20Commander">
<blockquote>Within CSSTidy, the file data.inc.php has some groupings of allowable CSS which might, I think, should be easily manipulated by functions (if not themselves grouped into modules) to remove groups of allowable values (e.g., if people didn't want certain colors allowed, certain properties (e.g., display which could hide elements), etc., as I saw discussed on one of your ideas pages).</blockquote>
<p>I noticed this. However, as of right now HTML Purifier is completely bypassing CSSTidy's validation/optimization logic, so all these validations are done on HTML Purifier's side (there's no way of guaranteeing the security of CSSTidy's validation either).</p>
</blockquote>

<p>You meant CSSTidy doesn't also guarantee security, right? I take it you're referring to bogus image insertions, etc.? Can we do something about that?</p>

<blockquote cite="Ambush%20Commander">
I am using CSSTidy almost solely for its parsing capabilities. It'll be interesting to see what from this file we can reuse, but it's non-OOP design makes it more difficult to jive with HTML Purifier.</blockquote>

<p>Not sure what you mean by non-OOP. It does use classes and objects and the like... Do you mean it doesn't fully take advantage of OOP features? If so, which ones?</p>

<blockquote cite="Ambush%20Commander">
<blockquote>Oh, also had the idea while looking at the units to have a function optionally auto-convert inches to cm, etc. :)</blockquote>
<p>An interesting idea, although it sounds a bit strange to me. I could easily hack it into HTMLPurifier_AttrDef_ChildDef_CSS_Length, but I can't see any practical use for it.</p></blockquote>

<p>No, this is not a pressing need. But some might prefer to work with a particular standard (and the rest of us in the world, (i.e., US, Liberia, and Myanmar) should already be using metric!)).</p>

<blockquote cite="Ambush%20Commander">
<blockquote>Also, do you have plans to add support for the style attribute too?</blockquote><p>If I do this, CSSTidy will need to be distributed with HTML Purifier, since style attribute validation is integral to HTML Purifier. I still need to analyze whether or not the parser can be used to parse style strings, and not actual style sheets.</p>
</blockquote>

<p>To parse a style string, couldn't you just encapsulate the whole string in a dummy class selector or the like and then strip it?</p>]]></description>
            <dc:creator>brettz9</dc:creator>
            <category>General</category>
            <pubDate>Mon, 18 Feb 2008 20:29:56 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1354#msg-1354</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1354#msg-1354</link>
            <description><![CDATA[<p>Indeed. This is a bug; I'll have a fix soon.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Mon, 18 Feb 2008 19:58:24 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1351#msg-1351</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1351#msg-1351</link>
            <description><![CDATA[<p>Just FYI, when using get('StyleBlocks'), if the CSS is wrapped in the usual &amp;amp;lt;!-- blah --&amp;amp;gt;, the StyleBlock output has &amp;quot;\3C !--&amp;quot; tacked on the front, with no corresponding close comment.</p>

<p>   -- hugh</p>]]></description>
            <dc:creator>cheesegrits</dc:creator>
            <category>General</category>
            <pubDate>Mon, 18 Feb 2008 13:42:26 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1121#msg-1121</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1121#msg-1121</link>
            <description><![CDATA[<blockquote>Within CSSTidy, the file data.inc.php has some groupings of allowable CSS which might, I think, should be easily manipulated by functions (if not themselves grouped into modules) to remove groups of allowable values (e.g., if people didn't want certain colors allowed, certain properties (e.g., display which could hide elements), etc., as I saw discussed on one of your ideas pages).</blockquote>

<p>I noticed this. However, as of right now HTML Purifier is completely bypassing CSSTidy's validation/optimization logic, so all these validations are done on HTML Purifier's side (there's no way of guaranteeing the security of CSSTidy's validation either). I am using CSSTidy almost solely for its parsing capabilities. It'll be interesting to see what from this file we can reuse, but it's non-OOP design makes it more difficult to jive with HTML Purifier.</p>

<blockquote>Oh, also had the idea while looking at the units to have a function optionally auto-convert inches to cm, etc. :)</blockquote>

<p>An interesting idea, although it sounds a bit strange to me. I could easily hack it into HTMLPurifier_AttrDef_ChildDef_CSS_Length, but I can't see any practical use for it.</p>

<blockquote>Also, do you have plans to add support for the style attribute too?</blockquote>

<p>If I do this, CSSTidy will need to be distributed with HTML Purifier, since style attribute validation is integral to HTML Purifier. I still need to analyze whether or not the parser can be used to parse style strings, and not actual style sheets.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Thu, 13 Dec 2007 12:59:42 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1120#msg-1120</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1120#msg-1120</link>
            <description><![CDATA[<p>Also, do you have plans to add support for the style attribute too?</p>]]></description>
            <dc:creator>brettz9</dc:creator>
            <category>General</category>
            <pubDate>Thu, 13 Dec 2007 09:35:26 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1119#msg-1119</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1119#msg-1119</link>
            <description><![CDATA[<p>Wonderful news!</p>

<p>Within CSSTidy, the file data.inc.php has some groupings of allowable CSS which might, I think, should be easily manipulated by functions (if not themselves grouped into modules) to remove groups of allowable values (e.g., if people didn't want certain colors allowed, certain properties (e.g., display which could hide elements), etc., as I saw discussed on one of your ideas pages).</p>

<p>Oh, also had the idea while looking at the units to have a function optionally auto-convert inches to cm, etc. :)</p>

<p>take care,
Brett</p>]]></description>
            <dc:creator>brettz9</dc:creator>
            <category>General</category>
            <pubDate>Thu, 13 Dec 2007 08:14:15 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1114#msg-1114</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1114#msg-1114</link>
            <description><![CDATA[<p>For those following this thread, experimental support for extracting &lt;style&gt; blocks and cleaning them has been added to trunk (PHP5-only) (thanks Chris for paying for this development!). Check out a copy of HTML Purifier repository and use this to test (note that <a href="http://csstidy.sourceforge.net/">CSSTidy</a> must be available on your system):</p>

<pre>
&lt;?php
// change these two paths as necessary
require_once 'class.csstidy.php';
require_once 'class.csstidy_print.php';
require_once 'HTMLPurifier/Filter/ExtractStyleBlocks.php';

$purifier = new HTMLPurifier();
$purifier-&gt;addFilter(new HTMLPurifier_Filter_ExtractStyleBlocks());
$text = $purifier-&gt;purify(
  '&lt;style&gt;.foo{text-align:left;bogus:foo;}&lt;/style&gt;'.
  '&lt;span class="foo"&gt;a&lt;/span&gt;'
);
print_r($text);
// '&lt;span class="foo"&gt;a&lt;/span&gt;'
print_r($purifier-&gt;context-&gt;get('StyleBlocks'));
/*
array
(
    0 =&gt; '.class {
text-align:left;
}'
)
*/
</pre>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Wed, 12 Dec 2007 17:56:48 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1029#msg-1029</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1029#msg-1029</link>
            <description><![CDATA[<p>HTML Purifier's development is in maintenance while PHP 4 is about to be deprecated. Once 2008 rolls around, development of new features will begin to pick up again.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Sat, 10 Nov 2007 01:32:42 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,1028#msg-1028</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,1028#msg-1028</link>
            <description><![CDATA[<p>So whats the progress on mergin it with CSS Tidy?</p>]]></description>
            <dc:creator>ericmn</dc:creator>
            <category>General</category>
            <pubDate>Fri, 09 Nov 2007 19:36:37 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,572#msg-572</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,572#msg-572</link>
            <description><![CDATA[<p>O.o That's pretty awesome. We might as well use it then. :-)</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Fri, 03 Aug 2007 16:39:51 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,571#msg-571</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,571#msg-571</link>
            <description><![CDATA[<p>Well, I can't cure the "Not Invented Here" syndrome (assuming it ought to be cured), but I just changed the license of CSS Tidy to LGPL with the approval of Flo (owner of the project). He still has to change the SF display of the license type, but you'll see that all the files use LGPL. :)  So feel free to borrow away...</p>]]></description>
            <dc:creator>Brett</dc:creator>
            <category>General</category>
            <pubDate>Fri, 03 Aug 2007 16:35:32 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,559#msg-559</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,559#msg-559</link>
            <description><![CDATA[<p>CSS Tidy suffers from "Not Invented Here" syndrome, also, its GPL license makes it difficult to integrate with HTML Purifier, which is LGPL. The general approach it takes, however, is basically what we need.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Fri, 03 Aug 2007 08:44:30 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,554#msg-554</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,554#msg-554</link>
            <description><![CDATA[<p>Hi,</p>

<p>Thanks.</p>

<p>I've recently come across what may be different than what you need to develop, but it seems to do the trick for me for CSS parsing (I recently joined the developers to make a few changes of my own and the project manager is looking for anyone to take over the project) and maybe it could be of some help to you in getting started?</p>

<p><a href="http://csstidy.sourceforge.net/">http://csstidy.sourceforge.net/</a></p>

<p>By the way, thanks for developing/working on something which was is so essential...</p>

<p>best wishes,
Brett</p>]]></description>
            <dc:creator>Brett</dc:creator>
            <category>General</category>
            <pubDate>Fri, 03 Aug 2007 06:17:53 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,552#msg-552</guid>
            <title>Re: CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,552#msg-552</link>
            <description><![CDATA[<p>Plans, yes. Means, no. Legitimate token based CSS parsing, and, by extension, parsing of style-sheets is scheduled for <a href="http://htmlpurifier.org/live/TODO">version 3</a>, although work on it will probably start earlier.</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>General</category>
            <pubDate>Thu, 02 Aug 2007 23:14:47 -0400</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?2,551,551#msg-551</guid>
            <title>CSS?</title>
            <link>http://htmlpurifier.org/phorum/read.php?2,551,551#msg-551</link>
            <description><![CDATA[<p>Hello,</p>

<p>Any means or plans to add the means for purifying CSS when injected into a stylesheet--i.e., when removing the &lt;style&gt; tags is not sufficient (i.e., removing javascript protocol from url(), etc.)?</p>

<p>thanks,
Brett</p>

<p>Edited 1 time(s). Last edit at 08/02/2007 11:13PM by Ambush Commander.</p>]]></description>
            <dc:creator>Brett</dc:creator>
            <category>General</category>
            <pubDate>Thu, 02 Aug 2007 21:38:06 -0400</pubDate>
        </item>
    </channel>
</rss>
