<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Defective Semantics &#187; xhtml</title>
	<atom:link href="http://scarff.id.au/blog/tag/xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://scarff.id.au</link>
	<description>Dean Scarff's perpetual struggle with technology, and other anecdotes</description>
	<lastBuildDate>Thu, 03 Nov 2011 22:39:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>XHTML fixes for the WordPress reCAPTCHA plugin</title>
		<link>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/</link>
		<comments>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:01:39 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=456</guid>
		<description><![CDATA[<p>The wp-recaptcha plugin for WordPress breaks when you&#8217;re serving pages as application/xhtml+xml.  I inadvertently broke comments when I installed it (silly me for not testing!).  I&#8217;ve written a patch that fixes it.</p>
<p>The default javascript API uses <code>document.write</code>, which isn&#8217;t a DOM method and hence is not a method of true XML documents.  It&#8217;s not a new issue either, wp-recaptcha has had a history of breaking XHTML.  The thing is, the WordPress plugin (which uses the PHP library by the recaptcha people) has an option to &#8220;Be XHTML 1.0 Strict compliant&#8221;; but this only fixes the use of iframes and noscript!</p>
<p><small class="postscript">Updated: pushed fork to github</small><br />
<span id="more-456"></span></p>
<p>Under firefox, you get an error like:</p>
<pre>
Error: uncaught exception:
[Exception... "Operation is not supported"  code: "9"
 nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
 location: "http://www.google.com/recaptcha/api/challenge?k=xxx Line: 12"]
</pre>
<p>While under Chrome it&#8217;s</p>
<pre>
Uncaught TypeError: Object #&#60;a Document&#62; has no method 'write'
api.recaptcha.net/challengek=xxx
</pre><p>&#8230; <a href="http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>The wp-recaptcha plugin for WordPress breaks when you&#8217;re serving pages as application/xhtml+xml.  I inadvertently broke comments when I installed it (silly me for not testing!).  I&#8217;ve written a patch that fixes it.</p>
<p>The default javascript API uses <code>document.write</code>, which isn&#8217;t a DOM method and hence is not a method of true XML documents.  It&#8217;s not a new issue either, wp-recaptcha has had a history of <a href="http://rickardandersson.com/recaptcha-and-xhtml">breaking XHTML</a>.  The thing is, the WordPress plugin (which uses the PHP library by the recaptcha people) has an option to &#8220;Be XHTML 1.0 Strict compliant&#8221;; but this only fixes the use of iframes and noscript!</p>
<p><small class="postscript">Updated: pushed fork to github</small><br />
<span id="more-456"></span></p>
<p>Under firefox, you get an error like:</p>
<pre>
Error: uncaught exception:
[Exception... "Operation is not supported"  code: "9"
 nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"
 location: "http://www.google.com/recaptcha/api/challenge?k=xxx Line: 12"]
</pre>
<p>While under Chrome it&#8217;s</p>
<pre>
Uncaught TypeError: Object #&lt;a Document&gt; has no method 'write'
api.recaptcha.net/challengek=xxx
</pre>
<p>The real solution is to use the <a href="http://code.google.com/apis/recaptcha/docs/display.html#AJAX">reCAPTCHA AJAX API</a>, which for whatever reason isn&#8217;t exposed in the PHP library.  You can grab my <a href="http://github.com/p00ya/wp-recaptcha">xml fix for wp-recaptcha</a> from github.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/xhtml-fixes-for-the-wordpress-recaptcha-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox NS_ERROR_INVALID_POINTER with innerHTML</title>
		<link>http://scarff.id.au/blog/2010/firefox-ns_error_invalid_pointer-with-innerhtml/</link>
		<comments>http://scarff.id.au/blog/2010/firefox-ns_error_invalid_pointer-with-innerhtml/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 04:33:46 +0000</pubDate>
		<dc:creator>Dean</dc:creator>
				<category><![CDATA[Problems]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prettify]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://scarff.id.au/?p=329</guid>
		<description><![CDATA[<p>When trying to use prettify here on Defective Semantics I ran into problems with firefox.  Here are the errors from the error console:</p>
<pre class="error">
Error: undefined entity
Error: uncaught exception: [Exception...
 "Component returned failure code: 0x80004003
 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]"
  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"
  location: "JS frame :: hxxp://example.net/prettify.js ::
             replaceWithPrettyPrintedHtml :: line 1414"
  data: no]
</pre>
<p>My insistence on trying to use XHTML on the blog is partly to blame.  Prettify tries to add &#8220;&#38;nbsp;&#8221; entities to the source (even if it&#8217;s a pre element) to appease Internet Explorer.  This entity only semi-works in XHTML: I&#8217;ve run into similar problems with some HTML entities not being loaded, because some browsers don&#8217;t load the DTD (which in turn loads the entity sets).  It also appears that while Firefox claims to support HTML latin 1 entities in a document with a PUBLIC XHTML identifier, it doesn&#8217;t actually reparse innerHTML assignments according to those&#8230; <a href="http://scarff.id.au/blog/2010/firefox-ns_error_invalid_pointer-with-innerhtml/" class="read_more">more</a></p>]]></description>
			<content:encoded><![CDATA[<p>When trying to use <a href="http://code.google.com/p/google-code-prettify/">prettify</a> here on Defective Semantics I ran into problems with firefox.  Here are the errors from the error console:</p>
<pre class="error">
Error: undefined entity
Error: uncaught exception: [Exception...
 "Component returned failure code: 0x80004003
 (NS_ERROR_INVALID_POINTER) [nsIDOMNSHTMLElement.innerHTML]"
  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"
  location: "JS frame :: hxxp://example.net/prettify.js ::
             replaceWithPrettyPrintedHtml :: line 1414"
  data: no]
</pre>
<p>My insistence on trying to use XHTML on the blog is partly to blame.  Prettify tries to add &#8220;&amp;nbsp;&#8221; entities to the source (even if it&#8217;s a pre element) to appease Internet Explorer.  This entity only semi-works in XHTML: I&#8217;ve run into similar problems with some HTML entities not being loaded, because some browsers don&#8217;t load the DTD (which in turn loads the entity sets).  It also appears that while Firefox <a href="https://developer.mozilla.org/en/XML_in_Mozilla#XHTML">claims to support HTML latin 1 entities</a> in a document with a PUBLIC XHTML identifier, it doesn&#8217;t actually reparse innerHTML assignments according to those rules.</p>
<p>My solution is to add a conditional test for XML.  Having a look at the <a href="https://developer.mozilla.org/en/DOM/document">Javascript document object</a> there doesn&#8217;t seem to be a <em>reliable</em> way to detect whether the browser is treating the document as XML from javascript.  My best attempt was:</p>
<pre class="codeblock javascript">
document.xmlVersion &#038;&#038; (document.compatMode=='CSS1Compat');
</pre>
<p>which works for Firefox and Opera.</p>
<p>As a separate issue, Chrome and Safari (and presumably anything WebKit based) don&#8217;t allow assignment of innerHTML for XML documents, giving <code class="error">NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7</code>.<br />
Fixing prettify to use only DOM methods instead of building up a string and assigning it to innerHTML could be a lot of work.  At least this exception, unlike the Firefox error, doesn&#8217;t leave the pretty-printed block in an inconsistent state.</p>
<p>I submitted a patch to the <a href="http://code.google.com/p/google-code-prettify/issues/detail?id=108">prettify issue tracker</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://scarff.id.au/blog/2010/firefox-ns_error_invalid_pointer-with-innerhtml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

