<?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/"
		>
<channel>
	<title>Comments on: ExternalInterface Bug with new line chars</title>
	<atom:link href="http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/</link>
	<description>code = joy</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:29:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Ola</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-21359</link>
		<dc:creator>Ola</dc:creator>
		<pubDate>Tue, 27 Apr 2010 20:19:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-21359</guid>
		<description>Thanks so much for that last comment (replace(/\\/g, “\\\\”))  -- saved my life.  Been searching most of the day for that answer...  Awesome!</description>
		<content:encoded><![CDATA[<p>Thanks so much for that last comment (replace(/\\/g, “\\\\”))  &#8212; saved my life.  Been searching most of the day for that answer&#8230;  Awesome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wes Carr</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-14862</link>
		<dc:creator>Wes Carr</dc:creator>
		<pubDate>Thu, 06 Nov 2008 23:01:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-14862</guid>
		<description>FYI, there appears to be a new bug in ExternalInterface serialization. Namely,

\\* is being converted to \* (where * is any character)

So now you need to do the following (AS3):
var data:String = stringToPass.replace(/\\/g, &quot;\\\\&quot; );

Tested in Flash 9 and 10.</description>
		<content:encoded><![CDATA[<p>FYI, there appears to be a new bug in ExternalInterface serialization. Namely,</p>
<p>\\* is being converted to \* (where * is any character)</p>
<p>So now you need to do the following (AS3):<br />
var data:String = stringToPass.replace(/\\/g, &#8220;\\\\&#8221; );</p>
<p>Tested in Flash 9 and 10.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ngoc</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-11659</link>
		<dc:creator>Ngoc</dc:creator>
		<pubDate>Tue, 25 Mar 2008 02:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-11659</guid>
		<description>When passing a string from AS to JS, AS wraps the string in double quote. This creates problem with backslashes.

Ex: to pass &#039;c:\&#039; to myfunc, AS will call myfunc(&quot;c:\&quot;), thus syntax error will occurs at JS side.</description>
		<content:encoded><![CDATA[<p>When passing a string from AS to JS, AS wraps the string in double quote. This creates problem with backslashes.</p>
<p>Ex: to pass &#8216;c:\&#8217; to myfunc, AS will call myfunc(&#8220;c:\&#8221;), thus syntax error will occurs at JS side.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel LaLiberte</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-10859</link>
		<dc:creator>Daniel LaLiberte</dc:creator>
		<pubDate>Wed, 16 Jan 2008 19:31:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-10859</guid>
		<description>So now if we pass the string containing &quot;\n&quot;, it will be passed correctly for one player and incorrectly for another.  So flash code must detect which player is being used, and do the encoding manually if it is not done automatically by the player?   And not all the necessary encoding is being done yet?  This is broken on top of broken.  

Probably best to avoid passing any strings with any troublesome characters.  I.e. strip out newlines, tabs, entities, backslashes, etc.  Or force the user to use a specific player, not newer or older.  Gack!</description>
		<content:encoded><![CDATA[<p>So now if we pass the string containing &#8220;\n&#8221;, it will be passed correctly for one player and incorrectly for another.  So flash code must detect which player is being used, and do the encoding manually if it is not done automatically by the player?   And not all the necessary encoding is being done yet?  This is broken on top of broken.  </p>
<p>Probably best to avoid passing any strings with any troublesome characters.  I.e. strip out newlines, tabs, entities, backslashes, etc.  Or force the user to use a specific player, not newer or older.  Gack!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Morton</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-7446</link>
		<dc:creator>Adam Morton</dc:creator>
		<pubDate>Fri, 04 May 2007 22:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-7446</guid>
		<description>Looks like the newline issue is fixed in 9,X, but not the entities or the backslashes.  And I&#039;m not set up to test the xml serialization so I can&#039;t speak to that.</description>
		<content:encoded><![CDATA[<p>Looks like the newline issue is fixed in 9,X, but not the entities or the backslashes.  And I&#8217;m not set up to test the xml serialization so I can&#8217;t speak to that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikechambers</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-7445</link>
		<dc:creator>mikechambers</dc:creator>
		<pubDate>Fri, 04 May 2007 18:01:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-7445</guid>
		<description>This issue has been fixed now for some time the public release builds of the player.

mike chambers

mesh@adobe.com</description>
		<content:encoded><![CDATA[<p>This issue has been fixed now for some time the public release builds of the player.</p>
<p>mike chambers</p>
<p><a href="mailto:mesh@adobe.com">mesh@adobe.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Morton</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-7444</link>
		<dc:creator>Adam Morton</dc:creator>
		<pubDate>Fri, 04 May 2007 17:14:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-7444</guid>
		<description>The replacements in Wes Carr&#039;s comment simplify to just replacing &#039;&amp;&#039; with &#039;&amp;&#039;

If you are just passing strings, you need to escape &#039;&amp;&#039;, backslashes, and the line endings when sending from AS to JS, and unescape on the JS side.

If you are passing objects, there are a host of other encoding issues in the xml serialization.  Brad Meuberg has fixed most of these in dojo, so take a look at that code if interested.

I&#039;m not sure the dojo code does the backslash escaping though, so if you use it and see your literal &#039;\t&#039; turning into a tab, update the encodeData AS function.

It is disappointing that Adobe/Macromedia would release this interface publicly with so many errors.  Adopters will necessarily have to fix it up on their own in in a superficial layer.  Which means, if and when Adobe actually fixes it, all the userspace fixes we have had to painfully determine and apply will then be rebroken.  Boo.  They should consider a rename and rerelease of the working interface to prevent this</description>
		<content:encoded><![CDATA[<p>The replacements in Wes Carr&#8217;s comment simplify to just replacing &#8216;&amp;&#8217; with &#8216;&amp;&#8217;</p>
<p>If you are just passing strings, you need to escape &#8216;&amp;&#8217;, backslashes, and the line endings when sending from AS to JS, and unescape on the JS side.</p>
<p>If you are passing objects, there are a host of other encoding issues in the xml serialization.  Brad Meuberg has fixed most of these in dojo, so take a look at that code if interested.</p>
<p>I&#8217;m not sure the dojo code does the backslash escaping though, so if you use it and see your literal &#8216;\t&#8217; turning into a tab, update the encodeData AS function.</p>
<p>It is disappointing that Adobe/Macromedia would release this interface publicly with so many errors.  Adopters will necessarily have to fix it up on their own in in a superficial layer.  Which means, if and when Adobe actually fixes it, all the userspace fixes we have had to painfully determine and apply will then be rebroken.  Boo.  They should consider a rename and rerelease of the working interface to prevent this</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brad Neuberg</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-6489</link>
		<dc:creator>Brad Neuberg</dc:creator>
		<pubDate>Fri, 13 Jan 2006 17:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-6489</guid>
		<description>It sounds like you used XML for your serialization format, but didn&#039;t surround the value sections with CDATA blocks:


  


That should help some of these problems, including having XML characters and entities misinterpreted. That is, if you didn&#039;t roll your own XML parser on the other side, which doesn&#039;t correctly handle CDATA sections, or are parsing out the XML with regular expressions....
</description>
		<content:encoded><![CDATA[<p>It sounds like you used XML for your serialization format, but didn&#8217;t surround the value sections with CDATA blocks:</p>
<p>That should help some of these problems, including having XML characters and entities misinterpreted. That is, if you didn&#8217;t roll your own XML parser on the other side, which doesn&#8217;t correctly handle CDATA sections, or are parsing out the XML with regular expressions&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kelvin Luck</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-6488</link>
		<dc:creator>Kelvin Luck</dc:creator>
		<pubDate>Wed, 11 Jan 2006 14:31:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-6488</guid>
		<description>Could you simplify your AS2 replacement function to this:

[code]
function escapeLineReturns(s:String):String
{
	return s.split(&quot;\n&quot;).join(&quot;\\n&quot;);
}
[/code]

? Not sure if it is less efficient but it seems to work for me...</description>
		<content:encoded><![CDATA[<p>Could you simplify your AS2 replacement function to this:</p>
<p>[code]<br />
function escapeLineReturns(s:String):String<br />
{<br />
	return s.split("\n").join("\\n");<br />
}<br />
[/code]</p>
<p>? Not sure if it is less efficient but it seems to work for me&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike chambers</title>
		<link>http://www.mikechambers.com/blog/2006/01/10/externalinterface-bug-with-new-line-chars/comment-page-1/#comment-6487</link>
		<dc:creator>mike chambers</dc:creator>
		<pubDate>Wed, 11 Jan 2006 03:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.mikechambers.com/blog/?p=936#comment-6487</guid>
		<description>Thanks. I just added these to the bug.

mike chambers

mesh@adobe.com</description>
		<content:encoded><![CDATA[<p>Thanks. I just added these to the bug.</p>
<p>mike chambers</p>
<p><a href="mailto:mesh@adobe.com">mesh@adobe.com</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
