Closed Bug 665025 Opened 13 years ago Closed 12 years ago

Very large string literals in XPI package JavaScript files cause validator to fail unexpectedly

Categories

(addons.mozilla.org Graveyard :: Add-on Validation, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: me, Unassigned)

References

()

Details

(Whiteboard: [streaming-json-parser])

Attachments

(4 files)

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
Build Identifier: current addons.mozilla.org website

I'm using the Addon SDK (formerly JetPack) to make a JavaScript based plugin for Firefox 4.  The plugin runs perfectly from the command line with 'cfx run' and I can package it with 'cfx xpi'.

When I go to submit my XPI to the website (https://addons.mozilla.org/en-US/developers/addon/submit/2) the Validation steps fails with "Unexpected server error while validating."

I proceeded to delete all my custom JS from my plugin, recreate an XPI, and upload again, and then the validation was successful -- so I knew this was not a temporary server issue.

Through a process of commenting out certain parts of my plugin JS code, recreating the XPI, and reuploading/revalidating I narrowed the problem down to some very large string literals in my plugin JS code.

I have code in the form of:

var x = 'foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar' +
'foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar' +
'foobarfoobarfoobarfoobarfoobarfoobarfoobarfoobar' +
...many more lines line that ...;

If the concatenation of the strings being saved into the variable x exceed something greater than 25-35KB then the XPI validator on addons.mozilla.org will fail with "Unexpected server error while validating."

However, if I break the > 30KB string into a few < 20KB strings... there are no problems.  So I can do:

var x = 'foo' + 'foo' + 'foo' + ... 15 more KB;
x += 'foo' + 'foo' + 'foo' + ... 15 more KB;
x += 'foo' + 'foo' + 'foo' + ... 15 more KB;
etc.

That works fine.  Again, however, if I just do:

var x = 'foo' + 'foo' + 'foo' + ... 40 more KB;

Now the validator will fail.



Reproducible: Always

Steps to Reproduce:
1. Create a plugin with the add-on SDK
2. Use the page-mod API to load in a JS file from your plugin's data folder with contentScriptFile
3. Add a JS string variable to the JS code as I described in the Details field of this bug report
4. Package as an XPI and submit to https://addons.mozilla.org/en-US/developers/addon/submit/

Actual Results:  
The XPI uploads and validates, but you get the error:
"Unexpected server error while validating."

Expected Results:  
I should have received a less generic error message about where/how the validator failed.  The validator also should not have failed in the first place.
Zachary, do you mind attaching the add-on which generated this error? Thanks!
In this version of the source I've applied my fix to get past the validation failure.
Attached file XPI with no problems
This XPI already fixed
Attached file XPI WITH Problem
This XPI will create unexpected validation failure.
Worked fine for me on the command line:

$ ./addon-validator firebomb-plugin.xpi 

Summary:
------------------------------
Detected type: Extension/Multi-Extension
------------------------------
Test failed! Errors:

Warning: Jetpack module hash unknown
Warning: Jetpack module hash unknown
Warning: Hidden files and folders flagged
This may be an issue with the prod python setup. The validator JSON output from the bad xpi has the following error

File \"/usr/lib/python2.6/json/scanner.py\", line 55, in iterscan
    rval, next_pos = action(m, context)
File \"/usr/lib/python2.6/json/decoder.py\", line 68, in JSONNumber
    res = fn(integer)
RuntimeError: maximum recursion depth exceeded while calling a Python object

Output cleaned up a little to make readable
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached file output from bad xpi
My output was from khan which is supposed to mirror production
Component: Developer Pages → Add-on Validation
QA Contact: developers → add-on-validation
This problem should have been fixed when we switched from `json` to `simplejson`. If it hasn't been, then this is another reason why we need a streaming JSON parser.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: [streaming-json-parser]
Don't json and simplejson trivially parse JSON from streams? Or do you mean something SAX-like?
SAX-like. We need something that's not based on recursion.
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: