<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: An html sanitizer for C#</title>
	<atom:link href="http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/</link>
	<description>think upstream</description>
	<lastBuildDate>Thu, 26 Jan 2012 17:19:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Roberto Bicchierai</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-429</link>
		<dc:creator><![CDATA[Roberto Bicchierai]]></dc:creator>
		<pubDate>Thu, 10 Nov 2011 09:27:02 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-429</guid>
		<description><![CDATA[Done.
thanks for remind me it!]]></description>
		<content:encoded><![CDATA[<p>Done.<br />
thanks for remind me it!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kibria</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-428</link>
		<dc:creator><![CDATA[kibria]]></dc:creator>
		<pubDate>Thu, 10 Nov 2011 08:27:35 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-428</guid>
		<description><![CDATA[Thanks a lot for sharing your code.
Please update the C# source file as fixed by Isaiah.]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot for sharing your code.<br />
Please update the C# source file as fixed by Isaiah.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Lebetsamer</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-364</link>
		<dc:creator><![CDATA[Eric Lebetsamer]]></dc:creator>
		<pubDate>Sun, 05 Dec 2010 12:04:36 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-364</guid>
		<description><![CDATA[Thanks for the fixes Isaiah.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the fixes Isaiah.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Isaiah</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-336</link>
		<dc:creator><![CDATA[Isaiah]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 17:13:04 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-336</guid>
		<description><![CDATA[Another correction (sorry):
buffer.Append(source.Substring(oldPos, search.Length)); is wrong, it should read

buffer.Append(source.Substring(oldPos, pos - oldPos));]]></description>
		<content:encoded><![CDATA[<p>Another correction (sorry):<br />
buffer.Append(source.Substring(oldPos, search.Length)); is wrong, it should read</p>
<p>buffer.Append(source.Substring(oldPos, pos &#8211; oldPos));</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Isaiah</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-335</link>
		<dc:creator><![CDATA[Isaiah]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 17:08:53 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-335</guid>
		<description><![CDATA[Correction: Bug #2 is ONLY in the C# code. The substring function in C# takes params start position, length, versus the one in java, which takes start position, end position.]]></description>
		<content:encoded><![CDATA[<p>Correction: Bug #2 is ONLY in the C# code. The substring function in C# takes params start position, length, versus the one in java, which takes start position, end position.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Isaiah</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-334</link>
		<dc:creator><![CDATA[Isaiah]]></dc:creator>
		<pubDate>Thu, 23 Sep 2010 16:22:37 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-334</guid>
		<description><![CDATA[I found a couple bugs, present in both the java and C# versions:

1. Self-closed tags were being converted to a pair of tags;
test case: &lt;param/&gt;&lt;param/&gt; becomes &lt;param&gt;&lt;param&gt;&lt;/param&gt;&lt;/param&gt;

2. Incorrect index in the replaceAllNoRegex function; 
buffer.Append(source.Substring(oldPos, pos));
should be
buffer.Append(source.Substring(oldPos, search.Length));

Here is a patch for the C#:

&lt;pre&gt;--- HtmlSanitizer.orig.cs	Thu Sep 23 12:17:54 2010
+++ HtmlSanitizer.new.cs	Thu Sep 23 12:18:03 2010
@@ -302,7 +302,10 @@
 
                             cleanToken = cleanToken + &quot; &quot; + attr + &quot;=\&quot;&quot; + val + &quot;\&quot;&quot;;
                         }
-                        cleanToken = cleanToken + &quot;&gt;&quot;;
+                        if (selfClosed.Match(token).Success)
+                            cleanToken = cleanToken + &quot;/&gt;&quot;;
+                        else
+                            cleanToken = cleanToken + &quot;&gt;&quot;;
 
                         isAcceptedToken = true;
 
@@ -316,7 +319,7 @@
                         token = cleanToken;
 
                         // push the tag if require closure and it is accepted (otherwise is encoded) 
-                        if (isAcceptedToken &amp;&amp; !(standAloneTags.Match(tag).Success &#124;&#124; selfClosed.Match(tag).Success))
+                        if (isAcceptedToken &amp;&amp; !(standAloneTags.Match(tag).Success &#124;&#124; selfClosed.Match(token).Success))
                             openTags.Push(tag);
 
                         // --------------------------------------------------------------------------------  UNKNOWN TAG 
@@ -601,7 +604,7 @@
                 int oldPos, pos;
                 for (oldPos = 0, pos = source.IndexOf(search, oldPos); pos != -1; oldPos = pos + search.Length, pos = source.IndexOf(search, oldPos))
                 {
-                    buffer.Append(source.Substring(oldPos, pos));
+                    buffer.Append(source.Substring(oldPos, search.Length));
                     buffer.Append(replace);
                 }
                 if (oldPos &lt; source.Length)&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>I found a couple bugs, present in both the java and C# versions:</p>
<p>1. Self-closed tags were being converted to a pair of tags;<br />
test case: &lt;param/&gt;&lt;param/&gt; becomes &lt;param&gt;&lt;param&gt;&lt;/param&gt;&lt;/param&gt;</p>
<p>2. Incorrect index in the replaceAllNoRegex function;<br />
buffer.Append(source.Substring(oldPos, pos));<br />
should be<br />
buffer.Append(source.Substring(oldPos, search.Length));</p>
<p>Here is a patch for the C#:</p>
<pre>--- HtmlSanitizer.orig.cs	Thu Sep 23 12:17:54 2010
+++ HtmlSanitizer.new.cs	Thu Sep 23 12:18:03 2010
@@ -302,7 +302,10 @@

                             cleanToken = cleanToken + " " + attr + "=\"" + val + "\"";
                         }
-                        cleanToken = cleanToken + "&gt;";
+                        if (selfClosed.Match(token).Success)
+                            cleanToken = cleanToken + "/&gt;";
+                        else
+                            cleanToken = cleanToken + "&gt;";

                         isAcceptedToken = true;

@@ -316,7 +319,7 @@
                         token = cleanToken;

                         // push the tag if require closure and it is accepted (otherwise is encoded)
-                        if (isAcceptedToken &amp;&amp; !(standAloneTags.Match(tag).Success || selfClosed.Match(tag).Success))
+                        if (isAcceptedToken &amp;&amp; !(standAloneTags.Match(tag).Success || selfClosed.Match(token).Success))
                             openTags.Push(tag);

                         // --------------------------------------------------------------------------------  UNKNOWN TAG
@@ -601,7 +604,7 @@
                 int oldPos, pos;
                 for (oldPos = 0, pos = source.IndexOf(search, oldPos); pos != -1; oldPos = pos + search.Length, pos = source.IndexOf(search, oldPos))
                 {
-                    buffer.Append(source.Substring(oldPos, pos));
+                    buffer.Append(source.Substring(oldPos, search.Length));
                     buffer.Append(replace);
                 }
                 if (oldPos &lt; source.Length)</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sal</title>
		<link>http://roberto.open-lab.com/2010/03/04/a-html-sanitizer-for-c/#comment-308</link>
		<dc:creator><![CDATA[Sal]]></dc:creator>
		<pubDate>Thu, 12 Aug 2010 08:28:09 +0000</pubDate>
		<guid isPermaLink="false">http://rbicchierai.wordpress.com/?p=442#comment-308</guid>
		<description><![CDATA[Ciao Roberto, complimenti per il codice, volevo segnalarti una cosa ... ho provato a copiare un testo proveniente da word (altro annoso problema) e ho notato che il codice lasciava un tag di chiusura del tipo o:p.

Saluti]]></description>
		<content:encoded><![CDATA[<p>Ciao Roberto, complimenti per il codice, volevo segnalarti una cosa &#8230; ho provato a copiare un testo proveniente da word (altro annoso problema) e ho notato che il codice lasciava un tag di chiusura del tipo o:p.</p>
<p>Saluti</p>
]]></content:encoded>
	</item>
</channel>
</rss>

