in reply to Re: RemoteObject.pm fails in open firefox8.0
in thread RemoteObject.pm fails in open firefox8.0

The error should happen in following code

... warn sprintf "(Sub)string is [%s]", substr($js,$offset,20); die $@ ...

The function is:

# Take a JSON response and convert it to a Perl data structure sub to_perl { my ($self,$js) = @_; local $_ = $js; #s/^(\.+\>\s*)+//; # remove Mozrepl continuation prompts s/^"//; s/"$//; if (/\.+>/) { # This should now be eliminated! die "Continuation prompt found in [$_]"; } #warn $js; # reraise JS errors from perspective of caller if (/^!!!\s+(.*)$/m) { croak "MozRepl::RemoteObject: $1"; }; if (! /\S/) { # We got an empty string back from the REPL ... warn "Got empty string from REPL"; return; } # In the case that we don't have a unicode string # already, decode the string from UTF-8 $js = decode('UTF-8', $_); #warn "[[$_]]"; my $res; local $@; my $json = $self->json; if (! eval { $res = $json->decode($js); #use Data::Dumper; #warn Dumper $res; 1 }) { my $err = $@; my $offset; if ($err =~ /character offset (\d+)\b/) { $offset = $1 }; $offset -= 10; $offset = 0 if $offset < 0; warn sprintf "(Sub)string is [%s]", substr($js,$offset,20); die $@ }; $res };

As i remember, with previous firefox releases(6.0,5.0,4.0), i encounter this problem occasionally. Now it happens always in firefox 8. How could avoid this problem?

Replies are listed 'Best First'.
Re^3: RemoteObject.pm fails in open firefox8.0
by Corion (Patriarch) on Oct 27, 2011 at 09:06 UTC

    Ah - this error occurs, because the JSON string is malformed. Most likely because the JSON string includes UTF-8, but the transport is not UTF-8 safe, as the warning message upon initialization says.

    As I said, I can't test it because Firefox 8 is in beta and not available as a portable installation. My recommendation is to avoid pages that need encoding outside the 7-bit ASCII characters.

    You could tell me what version of MozRepl::RemoteObject and WWW::Mechanize::Firefox and what version of the mozrepl plugin for Firefox you use. There are branches of mozrepl with UTF-8 safe transport, and I wonder why installing my own UTF-8-safe transport fails. But, again, I don't have your version of Firefox and thus can't test it.

      Hi, here attach the version of those modules :

      MozRepl::RemoteObject:0.28

      WWW::Mechanize::Firefox:0.45

      mozrepl is coming from "MozRepl 1.1beta2", but because it does not support firefox 8 by default, so I manually change the "install.rdf" to support firefox8.

      And the issue still happen in the latest firefox 8.0beta5, So I am afraid when 8.0 releases, problem still exist. I suggest making a change in advance.

        Your suggestion is duly noted but unless there is a convenient way to test with Firefox 8, I recommend you don't use it.

        My advice is to run your mission critical programs with Firefox 7 and disable automatic upgrades of major versions.