Great help Pablo. I'll have a look at this now. Looks good. Thanks!!!
Le jeudi 14 mars 2013 16:41:13 UTC, Pablo a écrit : > > Hi guys, > > I came accross this problem when building my own client framework. The > problem comes from the server failing to properly encode/scape single > quotes in the JSON response. > > Take a look at this file, the problem is addressed at the very beginning. > If the first attempt to decode the json string fails a second attempt is > made after single quotes are properly scaped, if it fails again the the > whole proccess/connection dies. > > https://github.com/ptejada/ApePubSub/blob/master/js/src/onMessage.js > > Hope you guys can properly port this temporary solution i came up with, > > Cheers > On Mar 14, 2013 12:20 PM, "Nicolas Guibert" > <[email protected]<javascript:>> > wrote: > >> Hi Louis, >> >> I already use decodeURIComponent but not encodeURIComponent. >> >> I'll add it and let you know if this helps. >> >> Thanks for your help. >> >> Nicolas. >> >> >> >> 2013/3/14 Louis Charette <[email protected] <javascript:>> >> >>> I would suggest using decodeURIComponent and encodeURIComponent on >>> your string before and after sending it. >>> >>> I don't have a vanilla APE setup on hand, but when I send "J'aime les >>> pommés" to a custom command I get back "J'aime%20les%20pomm%C3%A9s". >>> decodeURIComponent bring back the string clean again. >>> >>> Le 2013-03-14 à 11:48, Nicolas <[email protected] <javascript:>> >>> a écrit : >>> >>> Hi, >>> >>> I found a bug when sending a string that includes a single quote. >>> >>> To reproduce the bug, simply try sending a string that has a single >>> quote like this: >>> >>> pipe_user.sendRaw("name_raw",{"msg"," ' "); >>> >>> Then you will get a bug on Core.js on the client side (I use mootools >>> client) >>> >>> Does anybody know why the bug happens? Is there an easy way to correct >>> this? >>> >>> See below for the exact line of the bug. >>> >>> Thanks. >>> >>> Nicolas. >>> >>> >>> >>> >>> /*** >>> * Parse received data from Server >>> */ >>> parseResponse: function(raws, callback) { >>> if (raws) { >>> if (this.status < 0 ) { >>> this.failCounter = 0; >>> this.status = 1; >>> this.startPoller(); >>> this.fireEvent('apeReconnect'); >>> } >>> } >>> >>> var check = false; >>> var chlCallback;//Callback on challenge >>> >>> if (raws) { >>> raws = JSON.parse(raws); <<<<<================= This is where the error >>> is raised. Why? >>> Uncaught SyntaxError: Unexpected token ' (repeated 4 times) >>> if (!raws){ // Something went wrong, json decode failed >>> this.check(); >>> return; >>> } >>> >>> for (var i = 0; i < raws.length; i++){ //Read all raw >>> var raw = raws[i]; >>> >>> if (callback && $type(callback) == 'function') { >>> callback.run(raw); >>> } >>> >>> this.callRaw(raw); >>> >>> //Last request is finished and it's not an error >>> if (!this.transport.running()) { >>> if (!raw.data.code || (raw.data.code != '006' && raw.data.code != '007'&& >>> raw.data.code != '005' && raw.data.code!= '001' && raw.data.code != >>> '004' && raw.data.code != '003')) { >>> check = true; >>> } >>> } else { >>> //Invalidate check if something went wrong with other raw or a new >>> request have been launched >>> check = false; >>> } >>> } >>> } else if (!this.transport.running()) check = true; //No request >>> running, request didn't respond correct JSON, something went wrong >>> if (check) this.check(); >>> }, >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "APE Project" group. >>> To post to this group, send email to [email protected]<javascript:> >>> To unsubscribe from this group, send email to >>> [email protected] <javascript:> >>> For more options, visit this group at >>> http://groups.google.com/group/ape-project?hl=en >>> --- >>> APE Project (Ajax Push Engine) >>> Official website : http://www.ape-project.org/ >>> Git Hub : http://github.com/APE-Project/ >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "APE Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "APE Project" group. >>> To post to this group, send email to [email protected]<javascript:> >>> To unsubscribe from this group, send email to >>> [email protected] <javascript:> >>> For more options, visit this group at >>> http://groups.google.com/group/ape-project?hl=en >>> --- >>> APE Project (Ajax Push Engine) >>> Official website : http://www.ape-project.org/ >>> Git Hub : http://github.com/APE-Project/ >>> >>> --- >>> You received this message because you are subscribed to the Google >>> Groups "APE Project" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected] <javascript:>. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> >> >> <http://www.happymeeple.com> >> >> Nicolas Guibert >> >> Games in Mind Ltd >> >> Managing director >> >> 7 Spencer Walk >> >> Tel: +44 (0)207 435 0315 >> >> UK Mobile: +44 (0)7638 657 537 >> >> French Mobile: +33 (0)7 53 17 20 13 >> >> Email: [email protected] <javascript:> >> >> -- >> -- >> You received this message because you are subscribed to the Google >> Groups "APE Project" group. >> To post to this group, send email to [email protected]<javascript:> >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> For more options, visit this group at >> http://groups.google.com/group/ape-project?hl=en >> --- >> APE Project (Ajax Push Engine) >> Official website : http://www.ape-project.org/ >> Git Hub : http://github.com/APE-Project/ >> >> --- >> You received this message because you are subscribed to the Google Groups >> "APE Project" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- -- You received this message because you are subscribed to the Google Groups "APE Project" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/ape-project?hl=en --- APE Project (Ajax Push Engine) Official website : http://www.ape-project.org/ Git Hub : http://github.com/APE-Project/ --- You received this message because you are subscribed to the Google Groups "APE Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
