问题
(Note, this is intended as self-answer Q&A for a problem I encountered)
After trying to submit a WebExtension to Mozilla Add-Ons for public listing, the submission was rejected by a reviewer with the following message:
Your add-on includes a JavaScript library file that doesn't match any versions known to us. We require all add-ons to use unmodified release versions.
We accept JQuery/JQuery-UI libraries downloaded from 'ajax.googleapis.com', 'jquery.com' or 'jqueryui.com'; and used without any modification (downloaded and not copy pasted). Minified versions are better. (file-name change does not matter)
I'm sorry, but we cannot accept modified, re-configured or customized libraries.
Another symptom of the same problem: several "Unsafe assignment to innerHTML" warnings on initial validation coming from jQuery.
However, the file in question was indeed downloaded as a release, minified version from jquery.com and wasn't intentionally modified. So what happened?
回答1:
Turns out, even if you don't manually modify files, you can run into a situation when git
does it for you.
Specifically, automatic handling of CRLF line endings was modifying the jQuery's minified file, resulting in failed matching in the following situation:
- Download jQuery into the repo.
- Commit the file: line endings may be modified at this point.
- Build an archive for AMO; since the file was modified, it's rejected in review.
To prevent this happening, one can mark jQuery files as binary so that Git does not touch them under any circumstances, regardless of settings on a particular machine/repo.
Add a
.gitattributes
file somewhere in the chain of folders up to where jQuery is located, and assumingjquery.min.js
is the filename:jquery.min.js -text
Replace the copy of jQuery with a freshly downloaded one and commit it together with
.gitattributes
.
It might be a good idea to do it for all minified libraries.
If the library version is recognized, verification will show the following notice:
来源:https://stackoverflow.com/questions/45799095/mozilla-add-ons-rejecting-jquery-despite-not-being-modified