Anonymous avatar Anonymous committed 8cb7982

url-quote buckets and keys in jiak.php

Comments (0)

Files changed (1)

client_lib/jiak.php

         if ($read_mask == null)
             $read_mask = $allowed_fields;
         return $this->_expect(204,
-            $this->_do_req("PUT", $this->JKP . $bucket,
+            $this->_do_req("PUT", $this->JKP . urlencode($bucket),
                 json_encode( array (
                     "schema" => array (
                         "allowed_fields" => $allowed_fields,
     }
     
     function bucket_info($bucket) {
-        return $this->_expect(200, $this->_do_req("GET", $this->JKP . $bucket));
+        return $this->_expect(200,
+            $this->_do_req("GET", $this->JKP . urlencode($bucket)));
     }
     
     function store_all($ar) {
     function store($obj) {
         $new_data = $this->_expect(200,
             $this->_do_req("PUT",
-                $this->JKP . $obj->bucket . "/" . $obj->key .
-                "?returnbody=true",
+                $this->JKP . urlencode($obj->bucket) . "/" .
+                urlencode($obj->key) . "?returnbody=true",
                 $obj->to_json(),
                 array("Content-type: application/json;charset=UTF-8")));
         $obj->update($new_data);
     }
     
     function fetch($bucket, $key) {
-        $resp = $this->_do_req("GET", $this->JKP . $bucket . "/" . $key);
+        $resp = $this->_do_req("GET",
+                    $this->JKP . urlencode($bucket) . "/" . urlencode($key));
         if ($resp['http_code'] == 404) {
             return null;
         }
     
     function delete($bucket, $key) {
         $resp = $this->_do_req("DELETE", $this->JKP .
-            $bucket . "/" . $key);
+                    urlencode($bucket) . "/" . urlencode($key));
         $http_code = $resp['http_code'];
         if ($http_code == 404) return false;
         else if ($http_code == 204) return true;
     }
     
     function walk($bucket, $key, $spec) {
-        $resp = $this->_do_req("GET", $this->JKP . $bucket . "/" . $key . "/" .
-            $this->_convert_walk_spec($spec));
+        $resp = $this->_do_req("GET", $this->JKP . urlencode($bucket) .
+            "/" . urlencode($key) . "/" . $this->_convert_walk_spec($spec));
         
         if ($resp['http_code'] == 404) {
             return array();
     }
     
     function _convert_walk_spec($spec) {
-        $s = "/";
+        $s = "";
         foreach($spec as $el) {
-            $s .= $el[0] . "," . $el[1] . "," . $el[2] . ",";
+            $s .= urlencode($el[0]) . "," . urlencode($el[1]) . "," . $el[2] . "/";
         }
-        $s = str_replace(",\n", "", $s."\n");
         return $s;
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.