Some jQuery objects in various locations have been modified to use
text() to show values obtained from the server (except messages).
The text() will automatically encode special characters.

Ticket #1798

--
Endi S. Dewata
From 2af9922e6e271f1f48a47d20296facee5d6cb049 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Mon, 19 Sep 2011 21:04:57 -0500
Subject: [PATCH] Fixed problem displaying special characters.

Some jQuery objects in various locations have been modified to use
text() to show values obtained from the server (except messages).
The text() will automatically encode special characters.

Ticket #1798
---
 install/ui/automount.js             |    5 +++--
 install/ui/certificate.js           |   22 +++++++++++-----------
 install/ui/details.js               |    2 --
 install/ui/entitle.js               |    6 +++---
 install/ui/entity.js                |    5 ++++-
 install/ui/test/entity_tests.js     |    5 -----
 install/ui/test/navigation_tests.js |    4 ++--
 install/ui/widget.js                |   22 ++++++++++------------
 8 files changed, 33 insertions(+), 38 deletions(-)

diff --git a/install/ui/automount.js b/install/ui/automount.js
index e47a920ee78770363689d09710d39d2614320db8..7b322140d500b946635808dec82ca188ac7c14f8 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -199,7 +199,8 @@ IPA.entity_factories.automountkey = function() {
         build();
 };
 
-IPA.automount_key_column = function(spec){
+IPA.automount_key_column = function(spec) {
+
     var that = IPA.column(spec);
 
     that.setup = function(container, record) {
@@ -209,7 +210,7 @@ IPA.automount_key_column = function(spec){
 
         $('<a/>', {
             href: '#'+key,
-            html: key,
+            text: key,
             click: function() {
                 var state = IPA.nav.get_path_state(that.entity_name);
                 state[that.entity_name + '-facet'] = 'default';
diff --git a/install/ui/certificate.js b/install/ui/certificate.js
index 781b59ec48cbf784a9dd0f5a55598d3d32af5c06..15789fc1af8768d9326a5904456d7e6d97142953 100755
--- a/install/ui/certificate.js
+++ b/install/ui/certificate.js
@@ -232,25 +232,25 @@ IPA.cert.view_dialog = function(spec) {
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.common_name+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.subject.cn
+            text: that.subject.cn
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.organization+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.subject.o
+            text: that.subject.o
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.organizational_unit+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.subject.ou
+            text: that.subject.ou
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.serial_number+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.serial_number
+            text: that.serial_number
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
@@ -262,19 +262,19 @@ IPA.cert.view_dialog = function(spec) {
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.common_name+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.issuer.cn
+            text: that.issuer.cn
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.organization+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.issuer.o
+            text: that.issuer.o
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.organizational_unit+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.issuer.ou
+            text: that.issuer.ou
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
@@ -286,13 +286,13 @@ IPA.cert.view_dialog = function(spec) {
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.issued_on+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.issued_on
+            text: that.issued_on
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.expires_on+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.expires_on
+            text: that.expires_on
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
@@ -304,13 +304,13 @@ IPA.cert.view_dialog = function(spec) {
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.sha1_fingerprint+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.sha1_fingerprint
+            text: that.sha1_fingerprint
         }).appendTo(tr);
 
         tr = $('<tr/>').appendTo(table);
         $('<td>'+IPA.messages.objects.cert.md5_fingerprint+':</td>').appendTo(tr);
         $('<td/>', {
-            'html': that.md5_fingerprint
+            text: that.md5_fingerprint
         }).appendTo(tr);
     };
 
diff --git a/install/ui/details.js b/install/ui/details.js
index 1e3fc34846edd12a7b5707ff10f6e0609e0cc12c..6e5b6d21da250c390c201af4a43d92350099736b 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -204,7 +204,6 @@ IPA.details_section = function(spec) {
 
     // methods that should be invoked by subclasses
     that.section_create = that.create;
-    that.section_setup = that.setup;
     that.section_load = that.load;
     that.section_reset = that.reset;
 
@@ -706,7 +705,6 @@ IPA.details_facet = function(spec) {
 
     that.details_facet_create_content = that.create_content;
     that.details_facet_load = that.load;
-    that.details_facet_setup = that.setup;
 
     return that;
 };
diff --git a/install/ui/entitle.js b/install/ui/entitle.js
index 2687f6f9554e356ac3cb2ce2dd4420b01fd223db..c17afcf73c047325e93c70c01d74be0514d5aa5b 100644
--- a/install/ui/entitle.js
+++ b/install/ui/entitle.js
@@ -515,9 +515,9 @@ IPA.entitle.certificate_column = function(spec) {
         var certificate = record[that.name];
 
         $('<a/>', {
-            'href': '#download',
-            'html': IPA.messages.objects.entitle.download,
-            'click': function() {
+            href: '#download',
+            html: IPA.messages.objects.entitle.download,
+            click: function() {
                 var dialog = IPA.cert.download_dialog({
                     title: IPA.messages.objects.entitle.download_certificate,
                     certificate: certificate,
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 1ae233fe4873f92847be72987991cc38a11272a1..2c741022f269418bab8ed68bb7375ef9c80ba9f0 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -217,7 +217,10 @@ IPA.facet_header = function(spec) {
             }
 
             that.path.append(' &raquo; ');
-            that.path.append(value);
+
+            $('<span>', {
+                text: value
+            }).appendTo(that.path);
         }
 
         that.title_container.empty();
diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js
index a3561613af357883e9047854ec997dc52980e896..12a1fcae20d849883e089dcd0a014654facf88c3 100644
--- a/install/ui/test/entity_tests.js
+++ b/install/ui/test/entity_tests.js
@@ -101,10 +101,5 @@ test('Testing IPA.entity_set_search_definition().', function() {
         'column.label'
     );
 
-    ok(
-        column.setup,
-        'column.setup not null'
-    );
-
 });
 
diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js
index ece3b56d68fe35066978b0706c1cedb4d74b0a73..90e708ccb3daeb63031c76884bd69b608fbf5694 100644
--- a/install/ui/test/navigation_tests.js
+++ b/install/ui/test/navigation_tests.js
@@ -118,8 +118,8 @@ test("Testing IPA.navigation.update() with valid index.", function() {
         content: entity_container,
         tabs: [
             { name:'identity', label:'IDENTITY', children: [
-                {name:'one', label:'One', setup: function (){}},
-                {name:'two', label:'Two', setup: function (){}}
+                {name:'one', label:'One'},
+                {name:'two', label:'Two'}
             ]}
         ]
     });
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 2f607194985323fda93a97b5282f8b2fa6717eb5..fde6b0f2150da9f307922c5b06f5a9320b6b852d 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -445,7 +445,7 @@ IPA.text_widget = function(spec) {
         var value = that.values && that.values.length ? that.values[0] : '';
 
         if (that.read_only || !that.writable) {
-            that.display_control.html(value);
+            that.display_control.text(value);
             that.display_control.css('display', 'inline');
             that.input.css('display', 'none');
 
@@ -639,8 +639,8 @@ IPA.multivalued_text_widget = function(spec) {
 
         if (that.read_only || !that.writable) {
             var label = $('<label/>', {
-                'name': that.name,
-                'html': value
+                name: that.name,
+                text: value
             });
             input.replaceWith(label);
 
@@ -1137,7 +1137,7 @@ IPA.column = function (spec) {
         throw except;
     }
 
-    function setup(container, record) {
+    that.setup = function(container, record) {
 
         container.empty();
 
@@ -1150,18 +1150,16 @@ IPA.column = function (spec) {
         if (that.link) {
             $('<a/>', {
                 href: '#'+value,
-                html: value,
+                text: value,
                 click: function() {
                     return that.link_handler(value);
                 }
             }).appendTo(container);
 
         } else {
-            container.append(value);
+            container.text(value);
         }
-    }
-
-    that.setup = spec.setup || setup;
+    };
 
     that.link_handler = function(value) {
         return false;
@@ -1798,7 +1796,7 @@ IPA.combobox_widget = function(spec) {
     };
 
     that.set_value = function(value) {
-        that.text.html(value);
+        that.text.text(value);
         that.input.val(value);
     };
 
@@ -1919,8 +1917,8 @@ IPA.entity_link_widget = function(spec) {
     that.load = function (record){
         that.widget_load(record);
         if (that.values || that.values.length > 0){
-            that.nonlink.html(that.values[0]);
-            that.link.html(that.values[0]);
+            that.nonlink.text(that.values[0]);
+            that.link.text(that.values[0]);
             that.link.css('display','none');
             that.nonlink.css('display','inline');
         }else{
-- 
1.7.5.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to