Skip to content

Commit 3880aaf

Browse files
committed
MOBILE-4828 mathjax: Use ui/safe extension to prevent XSS
1 parent dad24a6 commit 3880aaf

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

scripts/copy-assets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const ASSETS = {
2323
'/node_modules/mathjax/es5/input/mml/extensions': '/lib/mathjax/input/mml/extensions',
2424
'/node_modules/mathjax/es5/input/tex/extensions': '/lib/mathjax/input/tex/extensions',
2525
'/node_modules/mathjax/es5/output/chtml/fonts/woff-v2': '/lib/mathjax/output/chtml/fonts/woff-v2',
26+
'/node_modules/mathjax/es5/ui/safe.js': '/lib/mathjax/ui/safe.js',
2627
'/node_modules/mp3-mediarecorder/dist/vmsg.wasm': '/lib/vmsg/vmsg.wasm',
2728
'/src/core/features/h5p/assets': '/lib/h5p',
2829
'/node_modules/ogv/dist': '/lib/ogv',

src/addons/filter/mathjaxloader/services/handlers/mathjaxloader.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ export class AddonFilterMathJaxLoaderHandlerService extends CoreFilterDefaultHan
4949

5050
// The MathJax configuration needs to be created before loading the MathJax script. Changing the options
5151
// after MathJax is initialized doesn't work (e.g. chaning window.MathJax.options or window.MathJax.config.options).
52+
// @todo: Obtain mathjaxconfig from the site.
5253
this.window.MathJax = {
5354
options: {
5455
enableMenu: false, // Disable right-click menu on equations.
5556
},
5657
startup: {
5758
typeset: false, // Don't run typeset automatically on the whole page when MathJax is loaded.
5859
},
60+
loader: {
61+
load: ['ui/safe'], // Prevent XSS.
62+
},
5963
};
6064

6165
// Add the script to the header.

0 commit comments

Comments
 (0)