From 42d92a0b371838b7f9877cefb4aa2745ab8cd24b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Mon, 22 Feb 2010 23:20:57 -0600 Subject: [PATCH] More ext-itex.js Fixes Ajax is asynchronous. Need to sanitize in the callback function, NOT when adding to the DOM. Need to unescape text for itex editor window (since JQuery seems to take care an 'extra' round of escaping). --- public/svg-edit/editor/extensions/ext-itex.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/svg-edit/editor/extensions/ext-itex.js b/public/svg-edit/editor/extensions/ext-itex.js index 83e74dad..493b9772 100644 --- a/public/svg-edit/editor/extensions/ext-itex.js +++ b/public/svg-edit/editor/extensions/ext-itex.js @@ -81,8 +81,8 @@ $(function() { semantics.appendChild(mrow); semantics.appendChild(annotation); math.appendChild(semantics); + S.sanitizeSvg(math); }); - S.sanitizeSvg(math); elt.replaceChild(math, elt.firstChild); S.call("changed", [elt]); svgCanvas.clearSelection(); @@ -94,6 +94,10 @@ $(function() { return true; }; + function unescapeHTML(str) { + return str.replace(/&/g, '&').replace(/</g, '<'); + } + function showItexEditor() { var elt = selElems[0]; var annotation = jQuery('math > semantics > annotation', elt); @@ -102,7 +106,7 @@ $(function() { toggleSourceButtons(true); // elt.removeAttribute('fill'); - var str = annotation.text(); + var str = unescapeHTML(annotation.text()); $('#svg_source_textarea').val(str); $('#svg_source_editor').fadeIn(); properlySourceSizeTextArea();