Commits

Diego Búrigo Zacarão committed 2c19abe

Fixed unescaping of HTML code when copying string in Lotte

Comments (0)

Files changed (2)

transifex/addons/lotte/media/js/tx.lotte2.js

         $('.lotte-actions a.copy_source').click(function() {
             var a=$(this);
             var plural_orig = $('.msg .source_string_plural', a.parents('tr'));
-            var orig=$('.msg .source_string', a.parents('tr')).whitespaceHighlight("reset"); //html();
+            var orig=$('.msg .source_string', a.parents('tr')).whitespaceHighlight("reset");
             if(plural_orig.length > 0)
               orig = orig.substring(orig.indexOf('</span>')+7);
             var trans=$('textarea.default_translation', a.parents('tr'));
-            trans.val(orig);
+            trans.val(html_unescape(orig));
             /* Mark the translated field as modified */
             id = parseInt(trans.attr("id").split("_")[1]); // Get the id of current textarea -> binding index
             string = this_stringset.strings[id];

transifex/media/js/base.js

   */
 function html_escape(html)
 {
-  var escaped = html;
-  escaped = escaped.replace(/&/g, "&amp;").replace(/</g, "&lt;")
+  return html.replace(/&/g, "&amp;").replace(/</g, "&lt;")
         .replace(/>/g, "&gt;").replace(/"/g, "&quot;");
-  return(escaped);
+}
+
+/** 
+  * This function unescapes the html elements found in a string!
+  */
+function html_unescape(html)
+{
+  return html.replace(/\&amp;/g, "&").replace(/\&lt;/g, "<")
+        .replace(/\&gt;/g, ">").replace(/\&quot;/g, "\"");
+
 }
 
 /**