Browse Source

HUE-1984 [hbase] url encode requests

URL encode on front end, then decode on backend.
Abraham Elmahrek 11 years ago
parent
commit
a29baab584
2 changed files with 5 additions and 3 deletions
  1. 3 1
      apps/hbase/src/hbase/views.py
  2. 2 2
      apps/hbase/static/js/api.js

+ 3 - 1
apps/hbase/src/hbase/views.py

@@ -21,6 +21,7 @@ import json
 import logging
 import re
 import StringIO
+import urllib
 
 from avro import schema, datafile, io
 
@@ -61,8 +62,9 @@ def api_router(request, url): # On split, deserialize anything
         data[i] = deserialize(item) # Sets local binding, needs to set in data
     return data
 
+  decoded_url_params = [urllib.unquote(arg) for arg in re.split(r'(?<!\\)/', url.strip('/'))]
   url_params = [safe_json_load((arg, request.POST.get(arg[0:16], arg))[arg[0:15] == 'hbase-post-key-'])
-                for arg in re.split(r'(?<!\\)/', url.strip('/'))] # Deserialize later
+                for arg in decoded_url_params] # Deserialize later
 
   if request.POST.get('dest', False):
     url_params += [request.FILES.get(request.REQUEST.get('dest'))]

+ 2 - 2
apps/hbase/static/js/api.js

@@ -31,9 +31,9 @@ var API = {
         $_POST[key] = arguments[i].slice(15);
         arguments[i] = key;
       }
-      url += '/' + arguments[i];
+      url += '/' + encodeURIComponent(arguments[i]);
     }
-    var queryObject = {url:url, method:'POST', startTime: new Date().getTime(), status:'running...'}
+    var queryObject = {url:url, method:'POST', startTime: new Date().getTime(), status:'running...'};
     var handler = $.post(url, $_POST).error(function(response) {
       $(document).trigger("error", JSON.parse(response.responseText).message);
     });