# Changing Object.prototype causes MathJax to crash #352

Closed
opened this issue Nov 13, 2012 · 3 comments

Projects
None yet
3 participants

### Tr0pe commented Nov 13, 2012

 If attribute is added to Object.prototype in section of HTML the MathJax will throw an error h.replace is not a function on the other hand adding attribute to Object.prototype in will cause MathJax to produce: [Math Processing Error]. Example:  
Member

### dpvc commented Nov 13, 2012

 OK, thanks for the report. It turns out that there is a missing check for hasOwnProperty in the file-loading code, and that is what was causing the problem when additional method were added to the Object prototype. I will fix it in the next release. In the meantime, you can use   to load MathJax, and it will patch the problem. Since the issue is in the file-loading code and that code is used to load configuration files, you can't load the configuration file until after the patch is applied. That means you can't use the config=... option in the script the loads MathJax since that file is loaded before the text/x-mathjax-config blocks are executed. So we put the configuration file into the config array in the code sample above. That also means you have to have this code in-line in your file and can't put it into a separate configuration file (since file loading is what is affected). The alternative would be to put off your Object modification until the so that the initial configuration file is loaded properly before that. Then you could use a configuration file of your own to store this patch. In that case, leave out the MathJax.Hub.Config call above.

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Nov 27, 2012

 Use hasOwnProperty() when checking file specification object (prevent… 
…s problems when Object.prototype has been modified). Resolves issue mathjax#352.
 9f1f495 
Member

### dpvc commented Nov 27, 2012

 The issue352 branch of my fork of MathJax should resolve this.
Contributor

### fred-wang commented Jan 5, 2013

 @Tr0pe: thanks for the test case. I'll integrate the test in my test commit: Crashtests/issue352.html I've verified the fix with Opera, Chrome and Firefox.

### dpvc pushed a commit to dpvc/MathJax that referenced this issue Mar 20, 2013

 Merge branch 'issue352' into develop. Resolves issue mathjax#352. 
 e9b5b59