Add missing character set definitions to data URIs.
authorPasi Kallinen <pasi.kallinen@pttk.fi>
Thu, 27 Jun 2013 08:23:11 +0000 (11:23 +0300)
committerJason Etheridge <jason@esilibrary.com>
Fri, 12 Jul 2013 20:16:56 +0000 (16:16 -0400)
Also use encodeURIComponent() instead of escape() so the UTF-8 characters stay intact.
Also, fix the print macro help popup window size.

Signed-off-by: Pasi Kallinen <pasi.kallinen@pttk.fi>
Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/web/opac/common/js/utils.js
Open-ILS/xul/staff_client/chrome/content/auth/controller.js
Open-ILS/xul/staff_client/chrome/content/util/error.js
Open-ILS/xul/staff_client/chrome/content/util/print.js
Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
Open-ILS/xul/staff_client/server/cat/marc_view.xul
Open-ILS/xul/staff_client/server/circ/print_list_template_editor.js
Open-ILS/xul/staff_client/server/patron/display.js

index 3d1366e..dae8ef2 100644 (file)
@@ -555,11 +555,11 @@ function interval_to_seconds( $interval ) {
 
 function openWindow( data ) {
        if( isXUL() ) {
-               var data = window.escape(
+               var data = window.encodeURIComponent(
                        '<html><head><title></title></head><body>' + data + '</body></html>');
 
                xulG.window_open(
-                       'data:text/html,' + data,
+                       'data:text/html;charset=UTF-8,' + data,
                        '', 
                        'chrome,resizable,width=700,height=500'); 
 
index 11b9e1a..bbd1979 100644 (file)
@@ -395,7 +395,7 @@ auth.controller.prototype = {
                 try {
                     if (x.readyState != 4) return;
                     if (x.status == 200) {
-                        window.open('data:text/html,'+window.escape(x.responseText),'upgrade','chrome,resizable,modal,centered');
+                        window.open('data:text/html;charset=UTF-8,'+window.encodeURIComponent(x.responseText),'upgrade','chrome,resizable,modal,centered');
                     } else {
                         if(typeof(G.upgradeCheck) == "function")
                         {
index f30605a..a865349 100644 (file)
@@ -317,7 +317,7 @@ util.error.prototype = {
         if (r == 1) {
             JSAN.use('util.window'); var win = new util.window();
             win.open(
-                'data:text/plain,' + window.escape( 'Please open a helpdesk ticket and include the following text: \n\n' + (new Date()) + '\n\n' + msg + '\n\n' + obj.pretty_print(js2JSON(E)) ),
+                'data:text/plain;charset=UTF-8,' + window.encodeURIComponent( 'Please open a helpdesk ticket and include the following text: \n\n' + (new Date()) + '\n\n' + msg + '\n\n' + obj.pretty_print(js2JSON(E)) ),
                 'error_alert',
                 'chrome,resizable,width=700,height=500'
             );
index 30e0ba7..075b0c1 100644 (file)
@@ -194,7 +194,7 @@ util.print.prototype = {
                     });
                 break;
                 default:
-                    w = obj.win.open('data:' + content_type + ',' + window.escape(msg),'receipt_temp','chrome,resizable');
+                    w = obj.win.open('data:' + content_type + ',' + window.encodeURIComponent(msg),'receipt_temp','chrome,resizable');
                     w.minimize();
                     setTimeout(
                         function() {
@@ -519,9 +519,9 @@ util.print.prototype = {
                             }
                         } else {
                             if (params.content_type == 'text/plain') {
-                                w = window.open('data:text/plain,'+escape(params.msg),'','chrome');
+                                w = window.open('data:text/plain;charset=UTF-8,'+encodeURIComponent(params.msg),'','chrome');
                             } else {
-                                w = window.open('data:text/html,'+escape(params.msg),'','chrome');
+                                w = window.open('data:text/html;charset=UTF-8,'+encodeURIComponent(params.msg),'','chrome');
                             }
                             setTimeout(
                                 function() {
@@ -544,9 +544,9 @@ util.print.prototype = {
                             obj._NSPrint_webBrowserPrint(w,silent,params);
                         } else {
                             if (params.content_type == 'text/plain') {
-                                w = window.open('data:text/plain,'+escape(params.msg),'','chrome');
+                                w = window.open('data:text/plain;charset=UTF-8,'+encodeURIComponent(params.msg),'','chrome');
                             } else {
-                                w = window.open('data:text/html,'+escape(params.msg),'','chrome');
+                                w = window.open('data:text/html;charset=UTF-8,'+encodeURIComponent(params.msg),'','chrome');
                             }
                             setTimeout(
                                 function() {
index 5531527..d5f36ef 100644 (file)
@@ -879,7 +879,7 @@ admin.offline_manage_xacts.prototype = {
             for (var i = 0; i < obj.sel_errors.length; i++) {
                 var error = obj.errors[ obj.sel_errors[i] ];
                 win.open(
-                    'data:text/plain,' + window.escape(
+                    'data:text/plain;charset=UTF-8,' + window.encodeURIComponent(
                         'Details:\n' + obj.error.pretty_print(js2JSON(error))
                     ),
                     'offline_error_details',
index 90b42e8..e600a49 100644 (file)
@@ -57,12 +57,12 @@ vim:noet:sw=4:ts=4:
                         function(req) {
                             var marc_html = req.getResultObject();
                             if (noprint||typeof xulG == 'undefined') marc_html = marc_html.replace(/<button.+?button>/, '');
-                            document.getElementById('marc_frame').setAttribute('src', 'data:text/html,' + encodeURIComponent(marc_html));
+                            document.getElementById('marc_frame').setAttribute('src', 'data:text/html;charset=UTF-8,' + encodeURIComponent(marc_html));
                         }
                     );
                 } else {
                     var marc_html = '<h1>' + document.getElementById('catStrings').getString('bib.no_marc') + '</h1>';
-                    document.getElementById('marc_frame').setAttribute('src', 'data:text/html,' + marc_html);
+                    document.getElementById('marc_frame').setAttribute('src', 'data:text/html;charset=UTF-8,' + marc_html);
                 }
 
             } catch(E) {
index dab6e2b..c846172 100644 (file)
@@ -254,9 +254,9 @@ circ.print_list_template_editor.prototype = {
                                     var macro_string = macros.join(', ');
                                     JSAN.use('util.window');
                                     var win = new util.window();
-                                    win.open('data:text/html,'
-                                        + window.escape(
-                                            '<html style="width: 600; height: 400;">'
+                                    win.open('data:text/html;charset=UTF-8,'
+                                        + window.encodeURIComponent(
+                                            '<html>'
                                             + '<head><title>' 
                                             + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.title')
                                             + '</title></head>'
@@ -281,7 +281,7 @@ circ.print_list_template_editor.prototype = {
                                             + document.getElementById('circStrings').getString('staff.circ.print_list_template.window.close')
                                             + '</button>'
                                             + '</body></html>'
-                                        ), 'title', 'chrome,resizable');
+                                        ), 'title', 'width=600,height=400,chrome,resizable');
                                 } catch(E) {
                                     alert(E);
                                 }
index 4728790..dab77bf 100644 (file)
@@ -413,9 +413,9 @@ patron.display.prototype = {
                         ['command'],
                         function(ev) {
                             if (obj.msg_url) {
-                                obj.right_deck.set_iframe('data:text/html,'+obj.msg_url,{},{});
+                                obj.right_deck.set_iframe('data:text/html;charset=UTF-8,'+obj.msg_url,{},{});
                             } else {
-                                obj.right_deck.set_iframe('data:text/html,<h1>' + $("patronStrings").getString('staff.patron.display.no_alerts_or_messages') + '</h1>',{},{});
+                                obj.right_deck.set_iframe('data:text/html;charset=UTF-8,<h1>' + $("patronStrings").getString('staff.patron.display.no_alerts_or_messages') + '</h1>',{},{});
                             }
                         }
                     ],
@@ -1047,10 +1047,10 @@ patron.display.prototype = {
                     if (msg != obj.old_msg) {
                         //obj.error.yns_alert(msg,'Alert Message','OK',null,null,'Check here to confirm this message.');
                         document.documentElement.firstChild.focus();
-                        var data_url = window.escape("<img src='" + xulG.url_prefix('/xul/server/skin/media/images/stop_sign.png') + "'/>" + '<h1>'
+                        var data_url = window.encodeURIComponent("<img src='" + xulG.url_prefix('/xul/server/skin/media/images/stop_sign.png') + "'/>" + '<h1>'
                             + $("patronStrings").getString('staff.patron.display.init.network_request.window_title') + '</h1><blockquote><p>' + msg + '</p>\r\n\r\n<pre>'
                             + $("patronStrings").getString('staff.patron.display.init.network_request.window_message') + '</pre></blockquote>');
-                        obj.right_deck.set_iframe('data:text/html,'+data_url,{},{});
+                        obj.right_deck.set_iframe('data:text/html;charset=UTF-8,'+data_url,{},{});
                         obj.old_msg = msg;
                         obj.msg_url = data_url;
                     } else {