DEVEX-2162: Replace urlencode() with rawurlencode().

This commit is contained in:
Matt Butcher
2012-02-27 14:05:03 -06:00
parent 4d14fd0762
commit 05e8615931
4 changed files with 16 additions and 16 deletions

View File

@@ -487,7 +487,7 @@ class CDN {
* The expected HTTP code. * The expected HTTP code.
*/ */
protected function modifyContainer($name, $method, $headers = array(), $qstring = '') { protected function modifyContainer($name, $method, $headers = array(), $qstring = '') {
$url = $this->url . '/' . urlencode($name) . $qstring; $url = $this->url . '/' . rawurlencode($name) . $qstring;
$headers['X-Auth-Token'] = $this->token; $headers['X-Auth-Token'] = $this->token;
$client = \HPCloud\Transport::instance(); $client = \HPCloud\Transport::instance();

View File

@@ -280,7 +280,7 @@ class ObjectStorage {
*/ */
public function container($name) { public function container($name) {
$url = $this->url() . '/' . urlencode($name); $url = $this->url() . '/' . rawurlencode($name);
$data = $this->req($url, 'HEAD', FALSE); $data = $this->req($url, 'HEAD', FALSE);
$status = $data->status(); $status = $data->status();
@@ -379,7 +379,7 @@ class ObjectStorage {
* created because it already exists. * created because it already exists.
*/ */
public function createContainer($name, ACL $acl = NULL, $metadata = array()) { public function createContainer($name, ACL $acl = NULL, $metadata = array()) {
$url = $this->url() . '/' . urlencode($name); $url = $this->url() . '/' . rawurlencode($name);
$headers = array( $headers = array(
'X-Auth-Token' => $this->token(), 'X-Auth-Token' => $this->token(),
); );
@@ -469,7 +469,7 @@ class ObjectStorage {
* results in a non-standard code. * results in a non-standard code.
*/ */
public function deleteContainer($name) { public function deleteContainer($name) {
$url = $this->url() . '/' . urlencode($name); $url = $this->url() . '/' . rawurlencode($name);
try { try {
$data = $this->req($url, 'DELETE', FALSE); $data = $this->req($url, 'DELETE', FALSE);

View File

@@ -127,7 +127,7 @@ class Container implements \Countable, \IteratorAggregate {
$oParts = explode('/', $oname); $oParts = explode('/', $oname);
$buffer = array(); $buffer = array();
foreach ($oParts as $part) { foreach ($oParts as $part) {
$buffer[] = urlencode($part); $buffer[] = rawurlencode($part);
} }
$newname = implode('/', $buffer); $newname = implode('/', $buffer);
return $base . '/' . $newname; return $base . '/' . $newname;
@@ -190,7 +190,7 @@ class Container implements \Countable, \IteratorAggregate {
$container->baseUrl = $url; $container->baseUrl = $url;
$container->url = $url . '/' . urlencode($jsonArray['name']); $container->url = $url . '/' . rawurlencode($jsonArray['name']);
$container->token = $token; $container->token = $token;
// Access to count and bytes is basically controlled. This is is to // Access to count and bytes is basically controlled. This is is to
@@ -233,7 +233,7 @@ class Container implements \Countable, \IteratorAggregate {
$container->bytes = $response->header('X-Container-Bytes-Used', 0); $container->bytes = $response->header('X-Container-Bytes-Used', 0);
$container->count = $response->header('X-Container-Object-Count', 0); $container->count = $response->header('X-Container-Object-Count', 0);
$container->baseUrl = $url; $container->baseUrl = $url;
$container->url = $url . '/' . urlencode($name); $container->url = $url . '/' . rawurlencode($name);
$container->token = $token; $container->token = $token;
$container->acl = ACL::newFromHeaders($response->headers()); $container->acl = ACL::newFromHeaders($response->headers());
@@ -396,7 +396,7 @@ class Container implements \Countable, \IteratorAggregate {
throw new \HPCloud\Exception('Container does not have a URL to send data.'); throw new \HPCloud\Exception('Container does not have a URL to send data.');
} }
//$url = $this->url . '/' . urlencode($obj->name()); //$url = $this->url . '/' . rawurlencode($obj->name());
$url = self::objectUrl($this->url, $obj->name()); $url = self::objectUrl($this->url, $obj->name());
// See if we have any metadata. // See if we have any metadata.
@@ -414,7 +414,7 @@ class Container implements \Countable, \IteratorAggregate {
// Add content encoding, if necessary. // Add content encoding, if necessary.
$encoding = $obj->encoding(); $encoding = $obj->encoding();
if (!empty($encoding)) { if (!empty($encoding)) {
$headers['Content-Encoding'] = urlencode($encoding); $headers['Content-Encoding'] = rawurlencode($encoding);
} }
// Add content disposition, if necessary. // Add content disposition, if necessary.
@@ -500,7 +500,7 @@ class Container implements \Countable, \IteratorAggregate {
* if the object does not already exist on the object storage. * if the object does not already exist on the object storage.
*/ */
public function updateMetadata(Object $obj) { public function updateMetadata(Object $obj) {
//$url = $this->url . '/' . urlencode($obj->name()); //$url = $this->url . '/' . rawurlencode($obj->name());
$url = self::objectUrl($this->url, $obj->name()); $url = self::objectUrl($this->url, $obj->name());
$headers = array(); $headers = array();
@@ -566,7 +566,7 @@ class Container implements \Countable, \IteratorAggregate {
if (empty($container)) { if (empty($container)) {
$container = $this->name; $container = $this->name;
} }
$container = urlencode($container); $container = rawurlencode($container);
$destUrl = self::objectUrl('/' . $container, $newName); $destUrl = self::objectUrl('/' . $container, $newName);
$headers = array( $headers = array(
@@ -928,7 +928,7 @@ class Container implements \Countable, \IteratorAggregate {
throw new \HPCloud\Exception('Unexpected entity returned.'); throw new \HPCloud\Exception('Unexpected entity returned.');
} }
else { else {
//$url = $this->url . '/' . urlencode($item['name']); //$url = $this->url . '/' . rawurlencode($item['name']);
$url = self::objectUrl($this->url, $item['name']); $url = self::objectUrl($this->url, $item['name']);
$list[] = RemoteObject::newFromJSON($item, $this->token, $url); $list[] = RemoteObject::newFromJSON($item, $this->token, $url);
} }

View File

@@ -42,7 +42,7 @@ use \HPCloud\Storage\ObjectStorage;
* `path/like/file/name.txt`. * `path/like/file/name.txt`.
* *
* A note on UTF-8 and URLs: PHP does not yet natively support many UTF-8 * A note on UTF-8 and URLs: PHP does not yet natively support many UTF-8
* characters in URLs. Thus, you ought to urlencode() your container name * characters in URLs. Thus, you ought to rawurlencode() your container name
* and object name (path) if there is any possibility that it will contain * and object name (path) if there is any possibility that it will contain
* UTF-8 characters. * UTF-8 characters.
* *
@@ -1037,7 +1037,7 @@ class StreamWrapper {
// $container = $this->store->container($url['host']); // $container = $this->store->container($url['host']);
$name = $url['host']; $name = $url['host'];
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . urlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token); $container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token);
return $container->delete($url['path']); return $container->delete($url['path']);
} }
@@ -1070,7 +1070,7 @@ class StreamWrapper {
//$container = $this->store->container($url['host']); //$container = $this->store->container($url['host']);
$name = $url['host']; $name = $url['host'];
$token = $this->store->token(); $token = $this->store->token();
$endpoint_url = $this->store->url() . '/' . urlencode($name); $endpoint_url = $this->store->url() . '/' . rawurlencode($name);
$container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token); $container = new \HPCloud\Storage\ObjectStorage\Container($name, $endpoint_url, $token);
$obj = $container->remoteObject($url['path']); $obj = $container->remoteObject($url['path']);
} }
@@ -1329,7 +1329,7 @@ class StreamWrapper {
* Parse a URL. * Parse a URL.
* *
* In order to provide full UTF-8 support, URLs must be * In order to provide full UTF-8 support, URLs must be
* urlencoded before they are passed into the stream wrapper. * rawurlencoded before they are passed into the stream wrapper.
* *
* This parses the URL and urldecodes the container name and * This parses the URL and urldecodes the container name and
* the object name. * the object name.