The $.bbq.getState() invocations have been modified not to coerce
URL parameter values to avoid parsing error.

Ticket #1208

--
Endi S. Dewata
From 0543036b5d59cb8769ee1857737fddf582613a13 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Mon, 23 May 2011 17:48:37 -0500
Subject: [PATCH] Fixed URL parameter parsing.

The $.bbq.getState() invocations have been modified not to coerce
URL parameter values to avoid parsing error.

Ticket #1208
---
 install/ui/associate.js  |   45 ++++++++++++++++++++++++++++++++++-----------
 install/ui/details.js    |    8 ++++----
 install/ui/dns.js        |   14 +++++++-------
 install/ui/entity.js     |   15 ++++++---------
 install/ui/hbac.js       |    8 ++++----
 install/ui/navigation.js |    2 +-
 install/ui/rule.js       |    2 +-
 install/ui/search.js     |   16 ++++++++--------
 install/ui/sudo.js       |   12 ++++++------
 install/ui/widget.js     |   23 -----------------------
 10 files changed, 71 insertions(+), 74 deletions(-)

diff --git a/install/ui/associate.js b/install/ui/associate.js
index b237d326f6bb0776633584599726e5eddd07bbbd..3ba510f10caf502cfa3323137b6a4eba27afbc72 100644
--- a/install/ui/associate.js
+++ b/install/ui/associate.js
@@ -527,7 +527,7 @@ IPA.association_table_widget = function (spec) {
     };
 
     that.create_add_dialog = function() {
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var label = IPA.metadata.objects[that.other_entity].label;
         var title = IPA.messages.association.add;
 
@@ -575,7 +575,7 @@ IPA.association_table_widget = function (spec) {
 
     that.add = function(values, on_success, on_error) {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var command = IPA.command({
             entity: that.entity_name,
@@ -600,7 +600,7 @@ IPA.association_table_widget = function (spec) {
             return;
         }
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var label = IPA.metadata.objects[that.other_entity].label;
         var title = IPA.messages.association.remove;
 
@@ -638,7 +638,7 @@ IPA.association_table_widget = function (spec) {
 
     that.remove = function(values, on_success, on_error) {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var command = IPA.command({
             entity: that.entity_name,
@@ -653,6 +653,29 @@ IPA.association_table_widget = function (spec) {
         command.execute();
     };
 
+    that.refresh = function() {
+
+        function on_success(data, text_status, xhr) {
+            that.load(data.result.result);
+        }
+
+        function on_error(xhr, text_status, error_thrown) {
+            var summary = $('span[name=summary]', that.tfoot).empty();
+            summary.append('<p>Error: '+error_thrown.name+'</p>');
+            summary.append('<p>'+error_thrown.message+'</p>');
+        }
+
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
+        IPA.command({
+            entity: that.entity_name,
+            method: 'show',
+            args: [pkey],
+            options: {'all': true, 'rights': true},
+            on_success: on_success,
+            on_error: on_error
+        }).execute();
+    };
+
     // methods that should be invoked by subclasses
     that.association_table_widget_init = that.init;
 
@@ -787,7 +810,7 @@ IPA.association_facet = function (spec) {
     };
 
     that.is_dirty = function() {
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         return pkey != that.pkey;
     };
 
@@ -795,7 +818,7 @@ IPA.association_facet = function (spec) {
 
         that.facet_create_header(container);
 
-        that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
         var other_label = IPA.metadata.objects[that.other_entity].label;
 
         var title = that.title;
@@ -845,7 +868,7 @@ IPA.association_facet = function (spec) {
     that.show = function() {
         that.facet_show();
 
-        that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
         that.entity.header.set_pkey(that.pkey);
 
         that.entity.header.back_link.css('visibility', 'visible');
@@ -854,7 +877,7 @@ IPA.association_facet = function (spec) {
 
     that.show_add_dialog = function() {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity;
         var title = IPA.messages.association.add;
 
@@ -877,7 +900,7 @@ IPA.association_facet = function (spec) {
 
         dialog.execute = function() {
 
-            var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+            var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
             var associator = that.associator({
                 'entity_name': that.entity_name,
@@ -915,7 +938,7 @@ IPA.association_facet = function (spec) {
             return;
         }
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var title = IPA.messages.association.remove;
 
         title = title.replace('${entity}', that.entity_name);
@@ -966,7 +989,7 @@ IPA.association_facet = function (spec) {
             'rights': true
         };
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var args =[];
         /* TODO: make a general solution to generate this value */
         var relationship_filter = 'in_' + that.entity_name;
diff --git a/install/ui/details.js b/install/ui/details.js
index a62b97fbd383c1342c4c04af7feb7502db867490..4af837e8ec5f78e6bce33885813abe884559f463 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -336,7 +336,7 @@ IPA.details_facet = function(spec) {
 
         that.facet_create_header(container);
 
-        that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
         var label = IPA.metadata.objects[that.entity_name].label;
 
         var title = that.title;
@@ -462,7 +462,7 @@ IPA.details_facet = function(spec) {
     that.show = function() {
         that.facet_show();
 
-        that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
         that.entity.header.set_pkey(that.pkey);
 
         if (that.entity.facets.length == 1) {
@@ -489,7 +489,7 @@ IPA.details_facet = function(spec) {
     };
 
     function new_key(){
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         return pkey != that.pkey;
     }
     that.new_key = new_key;
@@ -608,7 +608,7 @@ IPA.details_facet = function(spec) {
 
     that.refresh = function() {
 
-        that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var command = IPA.command({
             entity: that.entity_name,
diff --git a/install/ui/dns.js b/install/ui/dns.js
index f295145d5b346c8d49990fc675d26280097dc3c6..1c0ff6eeff457855dc8ec751f1f5981168da13cd 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -211,7 +211,7 @@ IPA.records_facet = function(spec) {
 
         dialog.add = function() {
 
-            var pkey = $.bbq.getState(that.entity_name+'-pkey', true);
+            var pkey = $.bbq.getState(that.entity_name+'-pkey');
             var resource = dialog.resource.val();
 
             var options = {};
@@ -244,7 +244,7 @@ IPA.records_facet = function(spec) {
             return;
         }
 
-        var zone = $.bbq.getState('dnszone-pkey', true);
+        var zone = $.bbq.getState('dnszone-pkey');
 
         var records = [];
 
@@ -330,8 +330,8 @@ IPA.records_facet = function(spec) {
     };
 
     that.is_dirty = function() {
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
-        var record = $.bbq.getState(that.entity_name + '-record', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
+        var record = $.bbq.getState(that.entity_name+'-record');
         return pkey != that.pkey || record != that.record;
     };
 
@@ -415,8 +415,8 @@ IPA.records_facet = function(spec) {
     that.show = function() {
         that.facet_show();
 
-        that.record = $.bbq.getState(that.entity_name + '-record', true) || '';
-        that.pkey = $.bbq.getState(that.entity_name+'-pkey', true) || '';
+        that.record = $.bbq.getState(that.entity_name+'-record');
+        that.pkey = $.bbq.getState(that.entity_name+'-pkey');
         that.entity.header.set_pkey(that.pkey);
 
         that.entity.header.back_link.css('visibility', 'visible');
@@ -497,7 +497,7 @@ IPA.records_facet = function(spec) {
             options.data = data_filter;
         }
 */
-        var args = [$.bbq.getState(that.entity_name + '-pkey', true)];
+        var args = [$.bbq.getState(that.entity_name+'-pkey')];
 
         if (filter) {
             args.push(filter);
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 889b6be38efd2ce11eea8546d3b2e7df06fae0fd..c855da1b5863dc9335de483650442c4f2af835e0 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -364,8 +364,7 @@ IPA.entity = function (spec) {
         var current_entity = that;
         current_entity = current_entity.containing_entity;
         while(current_entity !== null){
-            pkey.unshift(
-                $.bbq.getState(current_entity.name + '-pkey', true) || '');
+            pkey.unshift($.bbq.getState(current_entity.name+'-pkey'));
             current_entity = current_entity.containing_entity;
         }
         return pkey;
@@ -375,8 +374,7 @@ IPA.entity = function (spec) {
     that.get_primary_key = function() {
         var pkey = that.get_primary_key_prefix();
         var current_entity = that;
-        pkey.unshift(
-            $.bbq.getState(current_entity.name + '-pkey', true) || '');
+        pkey.unshift($.bbq.getState(current_entity.name+'-pkey'));
         return pkey;
     };
 
@@ -387,7 +385,7 @@ IPA.entity = function (spec) {
 };
 
 IPA.current_facet =  function (entity){
-    var facet_name = $.bbq.getState(entity.name + '-facet', true);
+    var facet_name = $.bbq.getState(entity.name+'-facet');
     var facets = entity.facets.values;
     if (!facet_name  && facets.length) {
         facet_name = facets[0].name;
@@ -473,7 +471,7 @@ IPA.entity_header = function(spec) {
 
     that.select_tab = function() {
         $(that.facet_tabs).find('a').removeClass('selected');
-        var facet_name = $.bbq.getState(that.entity.name + '-facet', true);
+        var facet_name = $.bbq.getState(that.entity.name+'-facet');
 
         if (!facet_name || facet_name === 'default') {
             that.facet_tabs.find('a:first').addClass('selected');
@@ -490,8 +488,7 @@ IPA.entity_header = function(spec) {
 
             while(current_entity){
                 breadcrumb.unshift($('<a/>',{
-                    text:$.bbq.getState(current_entity.name + '-pkey', true) ||
-                        '',
+                    text:$.bbq.getState(current_entity.name+'-pkey'),
                     title: current_entity.name,
                     click: function() {
                         var entity = IPA.get_entity((this.title));
@@ -538,7 +535,7 @@ IPA.entity_header = function(spec) {
                     return false;
                 }
 
-                var pkey = $.bbq.getState(that.entity.name+'-pkey', true);
+                var pkey = $.bbq.getState(that.entity.name+'-pkey');
 
                 IPA.nav.show_page(that.entity.name, other_facet.name, pkey);
                 $('a', that.facet_tabs).removeClass('selected');
diff --git a/install/ui/hbac.js b/install/ui/hbac.js
index 93ff7fbd5d48a831ab32a6f19fb884ab4ab5cc00..aa11879b8321438ab36ca9342b3e97ad9aa76cf7 100644
--- a/install/ui/hbac.js
+++ b/install/ui/hbac.js
@@ -341,7 +341,7 @@ IPA.hbacrule_details_facet = function (spec) {
 
     that.update = function() {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var modify_operation = {
             'execute': false,
@@ -837,7 +837,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
 
     that.add = function() {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var title = IPA.messages.association.add;
         title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label);
         title = title.replace('${primary_key}', pkey);
@@ -946,7 +946,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
             return;
         }
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         title = IPA.messages.association.remove;
         title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label);
         title = title.replace('${primary_key}', pkey);
@@ -1002,7 +1002,7 @@ IPA.hbacrule_accesstime_widget = function (spec) {
             summary.append('<p>'+error_thrown.message+'</p>');
         }
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         IPA.command({
             entity: that.entity_name,
             method: 'show',
diff --git a/install/ui/navigation.js b/install/ui/navigation.js
index 837cef1804166ffa97aefd06e43a9de6f99980bb..379573910d262328cdbe921e59b5a013ed7369f8 100644
--- a/install/ui/navigation.js
+++ b/install/ui/navigation.js
@@ -88,7 +88,7 @@ IPA.navigation = function(spec) {
     };
 
     that.get_state = function(key) {
-        return $.bbq.getState(key, true);
+        return $.bbq.getState(key);
     };
 
     that.remove_state = function(key) {
diff --git a/install/ui/rule.js b/install/ui/rule.js
index 8c69eca8b78713028d9b75a7ebcc7eba5a6a2113..08c27e6d16cc41b268ebfd630124096e5e413c12 100644
--- a/install/ui/rule.js
+++ b/install/ui/rule.js
@@ -134,7 +134,7 @@ IPA.rule_association_table_widget = function (spec) {
 
     that.add = function(values, on_success, on_error) {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var batch = IPA.batch_command({
             'on_success': on_success,
diff --git a/install/ui/search.js b/install/ui/search.js
index 450b8a655a3b8c167eed817f05c08e7fc0a6b3a5..5786886ac8459e5b0e34bb881cc20707dcab19eb 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -166,7 +166,7 @@ IPA.search_facet = function(spec) {
         that.entity.header.facet_tabs.css('visibility', 'hidden');
 
         if (that.filter) {
-            var filter = $.bbq.getState(that.entity_name + '-filter', true) || '';
+            var filter = $.bbq.getState(that.entity_name+'-filter');
             that.filter.val(filter);
         }
     };
@@ -295,17 +295,17 @@ IPA.search_facet = function(spec) {
             summary.append('<p>'+error_thrown.message+'</p>');
         }
 
+
         var filter = [];
         var current_entity = entity;
-        filter.unshift($.bbq.getState(current_entity.name + '-filter', true) || '');
+        filter.unshift($.bbq.getState(current_entity.name+'-filter'));
         current_entity = current_entity.containing_entity;
         while(current_entity !== null){
             filter.unshift(
-                $.bbq.getState(current_entity.name + '-pkey', true) || '');
+                $.bbq.getState(current_entity.name+'-pkey'));
             current_entity = current_entity.containing_entity;
         }
 
-
         var command = IPA.command({
             entity: entity.name,
             method: 'find',
@@ -343,17 +343,17 @@ IPA.nested_search_facet = function(spec){
         that.entity.header.facet_tabs.css('visibility', 'visible');
 
         that.entity.header.set_pkey(
-            $.bbq.getState(IPA.current_entity.name + '-pkey', true) || '');
+            $.bbq.getState(IPA.current_entity.name+'-pkey'));
+
         if (that.filter) {
-            var filter = 
-                $.bbq.getState(that.managed_entity_name + '-filter', true) || '';
+            var filter = $.bbq.getState(that.managed_entity_name+'-filter');
             that.filter.val(filter);
         }
     };
 
     that.refresh = function(){
 
-        var pkey = $.bbq.getState(that.entity.name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity.name+'-pkey');
 
         if ((!pkey) && (that.entity.redirect_facet)) {
 
diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 1b37b848864ca9843a204b2907c9137f65c08732..7bd6f4500c6593c08d14878d1d7193ee4c318073 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -197,7 +197,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
             'on_error': on_error
         });
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         for (var i=0; i<values.length; i++) {
             var value = values[i];
@@ -226,7 +226,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function (spec) {
             'on_error': on_error
         });
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         for (var i=0; i<values.length; i++) {
             var value = values[i];
@@ -354,7 +354,7 @@ IPA.sudorule_details_facet = function (spec) {
 
     that.update = function() {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var modify_operation = {
             'execute': false,
@@ -1042,7 +1042,7 @@ IPA.sudorule_association_table_widget = function (spec) {
     that.external = spec.external;
 
     that.create_add_dialog = function() {
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
         var label = IPA.metadata.objects[that.other_entity].label;
         var title = 'Add '+label+' to '+that.entity_name+' '+pkey;
 
@@ -1240,7 +1240,7 @@ IPA.sudorule_command_table_widget = function (spec) {
 
     that.add = function(values, on_success, on_error) {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var batch = IPA.batch_command({
             'on_success': on_success,
@@ -1278,7 +1278,7 @@ IPA.sudorule_command_table_widget = function (spec) {
 
     that.remove = function(values, on_success, on_error) {
 
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
+        var pkey = $.bbq.getState(that.entity_name+'-pkey');
 
         var command = IPA.command({
             entity: that.entity_name,
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 94c75d42b16457bf0a5960d8635ea60ca1413a43..6b211d6f46701ef4e3ddf47327d181e2618568a9 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1374,29 +1374,6 @@ IPA.table_widget = function (spec) {
         }
     };
 
-    that.refresh = function() {
-
-        function on_success(data, text_status, xhr) {
-            that.load(data.result.result);
-        }
-
-        function on_error(xhr, text_status, error_thrown) {
-            var summary = $('span[name=summary]', that.tfoot).empty();
-            summary.append('<p>Error: '+error_thrown.name+'</p>');
-            summary.append('<p>'+error_thrown.message+'</p>');
-        }
-
-        var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
-        IPA.command({
-            entity: that.entity_name,
-            method: 'show',
-            args: [pkey],
-            options: {'all': true, 'rights': true},
-            on_success: on_success,
-            on_error: on_error
-        }).execute();
-    };
-
     if (spec.columns) {
         for (var i=0; i<spec.columns; i++) {
             that.create_column(spec.columns[i]);
-- 
1.7.4

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

Reply via email to