Loading local (file://) mathjax scripts sometimes fails
Posted: Tue Nov 23, 2021 11:57 pm
I have been packaging some software for Debian GNU/Linux, and Firefox with NoScript has difficulties with some of the local webpages. I am using the Debian Firefox package, version 94.0-2, and NoScript version 11.2.11. An example of a package with the problem is python-py-stringmatching-doc, version 0.4.2+git20201204.6a7fb57-4. The HTML page BagDistance.html (/usr/share/doc/python3-py-stringmatching/html/BagDistance.html) was generated by Sphinx and begins as follows:
This is version 2.7.9 of MathJax, and I've modified the page to use the unpacked version of MathJax.js for debugging purposes; the behaviour is identical with the packed version.
With NoScript disabled, everything works fine. But with NoScript enabled, even with file: marked as Trusted, things go wrong and the console logs two error messages:
Loading failed for the <script> with source “file:///extensions/MathMenu.js?V=2.7.9”.
Loading failed for the <script> with source “file:///extensions/MathZoom.js?V=2.7.9”.
Tracing the execution shows that things go wrong at line 3137 of MathJax.js:
When NoScript is not running, "scripts" gets all 7 <script> elements in the HTML, but when NoScript is running, "scripts" only gets the first element:
And at this point in the JavaScript, document.documentElement has innerHTML value (according to the Web Developer tools, split over lines for clarity):
So it appears to have lost most of the webpage.
Worse than this, though, the behaviour is not consistent. For example, the python-abydos-doc package has a very similar webpage, /usr/share/doc/python3-abydos/html/abydos.distance.html, also generated by Sphinx, and this renders perfectly: the innerHTML value is the whole webpage, and getElementsByTagName returns all 7 script tag elements.
I cannot understand what NoScript has done here or why. Any suggestions would be most welcome!
Thanks, Julian
Code: Select all
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Bag Distance — py_stringmatching 0.4.2 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script async="async" src="file:///usr/share/javascript/mathjax/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script src="_static/js/theme.js"></script>
With NoScript disabled, everything works fine. But with NoScript enabled, even with file: marked as Trusted, things go wrong and the console logs two error messages:
Loading failed for the <script> with source “file:///extensions/MathMenu.js?V=2.7.9”.
Loading failed for the <script> with source “file:///extensions/MathZoom.js?V=2.7.9”.
Tracing the execution shows that things go wrong at line 3137 of MathJax.js:
Code: Select all
var scripts = (document.documentElement || document).getElementsByTagName("script");
Code: Select all
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Code: Select all
"<head>\n
<meta charset=\"utf-8\"><meta name=\"generator\" content=\"Docutils 0.17.1: http://docutils.sourceforge.net/\">\n\n
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n
<title>Bag Distance — py_stringmatching 0.4.2 documentation</title>\n
<link rel=\"stylesheet\" href=\"_static/pygments.css\" type=\"text/css\">\n
<link rel=\"stylesheet\" href=\"_static/css/theme.css\" type=\"text/css\">\n \n
<script data-url_root=\"./\" id=\"documentation_options\" src=\"_static/documentation_options.js\"></script></head>"
Worse than this, though, the behaviour is not consistent. For example, the python-abydos-doc package has a very similar webpage, /usr/share/doc/python3-abydos/html/abydos.distance.html, also generated by Sphinx, and this renders perfectly: the innerHTML value is the whole webpage, and getElementsByTagName returns all 7 script tag elements.
I cannot understand what NoScript has done here or why. Any suggestions would be most welcome!
Thanks, Julian