On 9/23/2011 6:51 AM, Petr Vobornik wrote:
On 09/20/2011 08:35 PM, Endi Sukma Dewata wrote:
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

I don't like the change in entity.js. Adding element simply because of
encoding string is wrong.

As agreed over IRC, the element might also be used to define the style, so I added a .breadcrumb-element class to the <span> and <a> elements.

Pushed to master and ipa-2-1.

--
Endi S. Dewata
From 501a45e5e8c6acd04f47c0cd952d93a7ccdd8165 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                |    7 ++++++-
 install/ui/test/entity_tests.js     |    5 -----
 install/ui/test/navigation_tests.js |    4 ++--
 install/ui/widget.js                |   22 ++++++++++------------
 8 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/install/ui/automount.js b/install/ui/automount.js
index 72ced6322bb333c8ba75cce543d511c73c20ddf4..a4fe166e18613b94b27ad048303715fc5d477d88 100644
--- a/install/ui/automount.js
+++ b/install/ui/automount.js
@@ -183,7 +183,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) {
@@ -193,7 +194,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 cecf97a61cb4e08d3f01997538cba01006d6a7e6..e25c45875bcf4950e0c3085fd3930aea764d35bb 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -205,7 +205,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;
 
@@ -720,7 +719,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 844c7ad4c6b9515aec3d06a5b360aed5ab5a2d67..b8cff6ee2b04a9b3bd4884ecfa8bf0a1bf238a9c 100644
--- a/install/ui/entitle.js
+++ b/install/ui/entitle.js
@@ -509,9 +509,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..3742360115d9dda51f35132b648d785a600d38f3 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -196,6 +196,7 @@ IPA.facet_header = function(spec) {
 
             while (entity) {
                 breadcrumb.unshift($('<a/>', {
+                    'class': 'breadcrumb-element',
                     text: IPA.nav.get_state(entity.name+'-pkey'),
                     title: entity.name,
                     click: function(entity) {
@@ -217,7 +218,11 @@ IPA.facet_header = function(spec) {
             }
 
             that.path.append(' &raquo; ');
-            that.path.append(value);
+
+            $('<span>', {
+                'class': 'breadcrumb-element',
+                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 0c07d655da2b29657925c2e13518d5c6d90f993a..f32dfbb18479fb5020e9ae7c2987e29321c833ef 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;
@@ -1764,7 +1762,7 @@ IPA.combobox_widget = function(spec) {
     };
 
     that.set_value = function(value) {
-        that.text.html(value);
+        that.text.text(value);
         that.input.val(value);
     };
 
@@ -1890,8 +1888,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