Skip Menu |

This queue is for tickets about the MozRepl-RemoteObject CPAN distribution.

Report information
The Basics
Id: 51216
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: MozRepl-RemoteObject

People
Owner: corion [...] cpan.org
Requestors: fayland [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



E:\Fayland\fayland\script\mech>perl firefox.pl invalid character encountered while parsing JSON string, at character offset 6663 (before "\x{14} and other pla...") at C:/strawberry/perl/site/lib/MozRepl/RemoteObject.pm line 165, <DATA> line 1. the code is use WWW::Mechanize::FireFox; my $mech = WWW::Mechanize::FireFox->new(); $mech->get('http://www.hotmail.com'); print $mech->content; Thanks
Subject: Re: [rt.cpan.org #51216]
Date: Mon, 9 Nov 2009 10:47:49 +0100 (CET)
To: bug-MozRepl-RemoteObject [...] rt.cpan.org
From: webmaster [...] corion.net
Hello, Show quoted text
> E:\Fayland\fayland\script\mech>perl firefox.pl > invalid character encountered while parsing JSON string, at character > offset 6663 (before "\x{14} and other pla...") at > C:/strawberry/perl/site/lib/MozRepl/RemoteObject.pm line 165, <DATA> line > 1. > > the code is > > use WWW::Mechanize::FireFox; > > my $mech = WWW::Mechanize::FireFox->new(); > $mech->get('http://www.hotmail.com'); > > print $mech->content;
This seems to be an error/miscommunication between MozRepl::RemoteObject, mozrepl and FireFox :-/ Can you please tell me the version of FireFox you're using this with? my $info = $mech->repl->appinfo() print join "\n", $info->{name}, $info->{version}, $info->{ID}; Most likely, whatever JSON encoder is used does something wrong. As a good test whether my "own" JSON encoder is at fault or a JSON encoder in the browser, you can change MozRepl::Plugin::JSON2: // add this line so "this.JSON" always gets our own JSON encoder this.JSON = undefined; if (this.JSON) { if (this.JSON.mozrepl) { // is this our own JSON implementation? this.JSON = undefined; // boom } } I'd like to use the native JSON encoder that comes with FireFox 3.5, but it seems that this encoder does not play well with JSON(::XS) because it uses \xHH escapes, which are not part of the JSON spec :-( -max
Subject: Re: [rt.cpan.org #51216]
Date: Mon, 9 Nov 2009 18:02:40 +0800
To: bug-MozRepl-RemoteObject [...] rt.cpan.org
From: Fayland Lam <fayland [...] gmail.com>
On Mon, Nov 9, 2009 at 5:48 PM, webmaster@corion.net via RT <bug-MozRepl-RemoteObject@rt.cpan.org> wrote: Show quoted text
> <URL: http://rt.cpan.org/Ticket/Display.html?id=51216 > > > Hello, >
>> E:\Fayland\fayland\script\mech>perl firefox.pl >> invalid character encountered while parsing JSON string, at character >> offset 6663 (before "\x{14} and other pla...") at >> C:/strawberry/perl/site/lib/MozRepl/RemoteObject.pm line 165, <DATA> line >> 1. >> >> the code is >> >> use WWW::Mechanize::FireFox; >> >> my $mech = WWW::Mechanize::FireFox->new(); >> $mech->get('http://www.hotmail.com'); >> >> print $mech->content;
> This seems to be an error/miscommunication between MozRepl::RemoteObject, > mozrepl and FireFox :-/ > > Can you please tell me the version of FireFox you're using this with? > >  my $info = $mech->repl->appinfo() >  print join "\n", $info->{name}, $info->{version}, $info->{ID};
Firefox 3.5.5 {ec8030f7-c20a-464f-9b0e-13a3a9e97384} Show quoted text
> > Most likely, whatever JSON encoder is used does something wrong. As a good > test whether my "own" JSON encoder is at fault or a JSON encoder in the > browser, you can change MozRepl::Plugin::JSON2: > > // add this line so "this.JSON" always gets our own JSON encoder > this.JSON = undefined; > if (this.JSON) { >    if (this.JSON.mozrepl) {   // is this our own JSON implementation? >        this.JSON = undefined; // boom >    } > }
well, the test cases are failed too. t/03-unicode...........1/4 # Failed test 'We can pass unicode-titles from JS to Perl and get characters' # at t/03-unicode.t line 41. Wide character in print at C:/STRAWB~1/perl/lib/Test/Builder.pm line 1472, <DATA Show quoted text
> line 1.
# got: '陆眉路茫毛没脥脙脠茂眉颅贸掳 碌眉脫鹿 [mixi(脽炉路拢)]' # expected: '銈姐兗銈枫儯銉兓銉嶃儍銉堛儻銉笺偔銉炽偘 銈点兗銉撱偣 [mixi( 銉熴偗銈枫偅)]' # Looks like you failed 1 test of 4. t/03-unicode........... Dubious, test returned 1 (wstat 256, 0x100) Failed 1/4 subtests t/04-appversion........1/1 # ID : {ec8030f7-c20a-464f-9b0e-13a3a9e97384} # name : Firefox # version : 3.5.5 Thanks Show quoted text
> > I'd like to use the native JSON encoder that comes with FireFox 3.5, but > it seems that this encoder does not play well with JSON(::XS) because it > uses \xHH escapes, which are not part of the JSON spec :-( > > -max > > >
-- Fayland Lam // http://www.fayland.org/
Closed by making MozRepl::RemoteObject always use its own JSON encoder, which only encodes ASCII and thus circumvents the encoding problems between FireFox, mozrepl and JSON.pm