Navigation Menu

Skip to content

Commit

Permalink
escape globally
Browse files Browse the repository at this point in the history
  • Loading branch information
Masahiro Chiba committed Oct 19, 2009
1 parent f018782 commit 08c583a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions as/JSocket.as
Expand Up @@ -10,6 +10,7 @@ package {
{
private var sockets:Array = new Array();
private var handlers:Object;
private var escapeReg:RegExp = /\\/g;

public function JSocket():void {
if (stage) init();
Expand Down Expand Up @@ -66,11 +67,11 @@ package {
private function dataHandler(event:Event, socid:int):void {
var soc:Socket = sockets[socid];
var buffer:String = soc.readUTFBytes(soc.bytesAvailable);
ExternalInterface.call('JSocket.handler', socid, 'dataHandler', buffer.replace('\\', '\\\\'));
ExternalInterface.call('JSocket.handler', socid, 'dataHandler', buffer.replace(escapeReg, '\\\\'));
}

private function errorHandler(event:Event, socid:int):void {
ExternalInterface.call('JSocket.handler', socid, 'errorHandler', event.toString().replace('\\', '\\\\'));
ExternalInterface.call('JSocket.handler', socid, 'errorHandler', event.toString().replace(escapeReg, '\\\\'));
}
}
}
2 changes: 1 addition & 1 deletion js/jsocket.js
Expand Up @@ -33,7 +33,7 @@
function JSocket() {
this.initialize.apply(this, arguments);
}
JSocket.VERSION = '0.01';
JSocket.VERSION = '0.02';
JSocket.init = function(src, swfloadedcb) {
JSocket.flashapi = $('<div></div>').appendTo('body').flashembed({
id: 'socketswf',
Expand Down
Binary file modified swf/JSocket.swf
Binary file not shown.

0 comments on commit 08c583a

Please sign in to comment.