jkanko has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a project utilizing www-mechanize-firefox and I'm getting an invalid character error to mozrepl & json that is killing my proggie:

(Sub)string is [tle>\n\n\n \n \n <] at +C:/Perl/si te/lib/MozRepl/RemoteObject.pm line 191, <DATA> line 1. invalid character encountered while parsing JSON string, at character +offset 121 (before "\t\n\t\t\n\t\t<meta ...") at C:/Perl/site/lib/MozRepl/Remote +Object.pm line 181


I'm not sure if I should get rid of a "die on error" or if there is a handler I can use to get past this...

The code is fairly simple: $mech = WWW::Mechanize::FireFox->new( autocheck => 1 ); $mech->get( " __fooz__barz__ " ); $mech->follow_link( text => 'View all' );

I intermittently get the error on the initial page load and also after the follow link. The page is using embedded js on aspx...

Replies are listed 'Best First'.
Re: mozrepl invalid characters
by Corion (Patriarch) on May 12, 2010 at 20:40 UTC

    This is usually when the result contains UTF-8 characters or Latin-1 characters when JSON is not expecting them. I've tried to escape/encode them in the recent versions of WWW::Mechanize::Firefox. From looking at your code, it seems you're using a very early version of the module when it was still named ::FireFox. Consider upgrading to the latest release which should handle weird encodings far better.

      Switched over to Linux and got newest package and it's working swimmingly. Thanks!