Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-26798 encode file path in dropbox repository plugin, credits to M…

…yles Carrick
  • Loading branch information...
commit 77bfc4ce0f92b0426ae7800c196cc56e0540606a 1 parent 13c53a4
@mylescarrick mylescarrick authored samhemelryk committed
Showing with 5 additions and 8 deletions.
  1. +3 −7 repository/dropbox/lib.php
  2. +2 −1  repository/dropbox/locallib.php
View
10 repository/dropbox/lib.php
@@ -19,11 +19,6 @@
* repository_dropbox class
* This plugin is used to access user's dropbox files
*
- * TODO:
- * Dropbox has problems to process filepath with spaces, tried to use
- * urlencode filepath, still doesn't work
- * http://code.google.com/p/dropbox-php/ has the same problem
- *
* @since 2.0
* @package repository
* @subpackage dropbox
@@ -130,18 +125,19 @@ public function get_listing($path = '', $page = '1') {
} else {
$path = file_correct_filepath($path);
}
+ $encoded_path = str_replace("%2F", "/", rawurlencode($path));
$list = array();
$list['list'] = array();
$list['manage'] = false;
$list['dynload'] = true;
$list['nosearch'] = true;
- // process breacrumb trail
+ // process breadcrumb trail
$list['path'] = array(
array('name'=>get_string('dropbox', 'repository_dropbox'), 'path'=>'/')
);
- $result = $this->dropbox->get_listing($path, $this->access_key, $this->access_secret);
+ $result = $this->dropbox->get_listing($encoded_path, $this->access_key, $this->access_secret);
if (!is_object($result) || empty($result)) {
return $list;
View
3  repository/dropbox/locallib.php
@@ -70,7 +70,8 @@ public function get_file($filepath, $saveas) {
$basename = $info['basename'];
$filepath = $dirname . rawurlencode($basename);
if ($dirname != '/') {
- $filepath = $dirname . '/' . rawurlencode($basename);
+ $filepath = $dirname . '/' . $basename;
+ $filepath = str_replace("%2F", "/", rawurlencode($filepath));
}
$url = $this->dropbox_content_api.'/files/'.$this->mode.$filepath;
Please sign in to comment.
Something went wrong with that request. Please try again.