From c526b2a5c58ae8e2549303d5649c1364e3085f08 Mon Sep 17 00:00:00 2001
From: "physikerwelt (Moritz Schubotz)" <wiki@physikerwelt.de>
Date: Tue, 14 Oct 2014 18:34:36 +0200
Subject: [PATCH] XML-escape TeX annotation

---
 unpacked/extensions/toMathML.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/unpacked/extensions/toMathML.js b/unpacked/extensions/toMathML.js
index aae34f73a..8ea82e383 100644
--- a/unpacked/extensions/toMathML.js
+++ b/unpacked/extensions/toMathML.js
@@ -160,7 +160,10 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
       if (annotation) {
         if (nested) {data.unshift(space+"    <mrow>"); data.push(space+"    </mrow>")}
         data.unshift(space+"  <semantics>");
-        data.push(space+'    <annotation encoding="'+annotation+'">'+jax.originalText+"</annotation>");
+        var xmlEscapedTex = jax.originalText.replace(/([&<>])/g, function(item) {
+            return { '>': '&gt;', '<': '&lt;','&': '&amp;' }[item]
+        });
+      data.push(space+'    <annotation encoding="'+annotation+'">'+xmlEscapedTex+"</annotation>");
         data.push(space+"  </semantics>");
       }
       return space+"<"+tag+attr+">\n"+data.join("\n")+"\n"+space+"</"+tag+">";
-- 
GitLab