Skip to content

Commit bb9a1ae

Browse files
authored
Merge pull request #337 from mathjax/330
[main] config: sanitize MathJax configuration
2 parents c7f8cc5 + 985837b commit bb9a1ae

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

lib/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,5 +867,9 @@ exports.config = function (config) {
867867
if (config.undefinedCharError != null) {undefinedChar = config.undefinedCharError}
868868
if (config.extensions != null) {extensions = config.extensions}
869869
if (config.fontURL != null) {fontURL = config.fontURL}
870-
if (config.MathJax) {MathJaxConfig = config.MathJax}
870+
if (config.MathJax) {
871+
// strip MathJax config blocks to avoid errors
872+
if (config.MathJax.config) delete config.MathJax.config
873+
MathJaxConfig = config.MathJax
874+
}
871875
}

test/mathjax-config-combined.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/main.js");
3+
var jsdom = require('jsdom').jsdom;
4+
5+
tape('MathJax configuration: strip config block', function (t) {
6+
t.plan(1);
7+
mjAPI.config({
8+
MathJax: {
9+
config: ["TeX-AMS_SVG.js"]
10+
}
11+
});
12+
mjAPI.typeset({
13+
math: 'E = mc^2',
14+
format: "TeX",
15+
mml: true,
16+
}, function (data) {
17+
t.ok(data, 'Config block did not cause errors');
18+
});
19+
20+
});

0 commit comments

Comments
 (0)