Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mozilla Add-Ons rejecting jQuery (despite not being modified)

(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.

enter image description here

However, the file in question was indeed downloaded as a release, minified version from jquery.com and wasn't intentionally modified. So what happened?

like image 602
Xan Avatar asked Aug 21 '17 14:08

Xan


1 Answers

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.

  1. Add a .gitattributes file somewhere in the chain of folders up to where jQuery is located, and assuming jquery.min.js is the filename:

    jquery.min.js -text
    
  2. 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:

enter image description here

like image 171
Xan Avatar answered Sep 28 '22 02:09

Xan