Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-30154_21_wip' of git://github.com/grabs/moodle into…

… MOODLE_21_STABLE
  • Loading branch information...
commit d4d070fc35f422dbea35f524820710dcd78ce268 2 parents 2331e2e + 280854d
Aparup Banerjee nebgor authored
Showing with 37 additions and 10 deletions.
  1. +35 −9 lib/webdavlib.php
  2. +2 −1  repository/webdav/lib.php
44 lib/webdavlib.php
View
@@ -797,7 +797,7 @@ function ls($path) {
if (strcmp($response['status']['status-code'],'207') == 0 ) {
// ok so far
// next there should be a Content-Type: text/xml; charset="utf-8" header line
- if (preg_match('#text/xml;\s?charset=[\'\"]?utf-8[\'\"]?#i', $response['header']['Content-Type'])) {
+ if (preg_match('#(application|text)/xml;\s?charset=[\'\"]?utf-8[\'\"]?#i', $response['header']['Content-Type'])) {
// ok let's get the content of the xml stuff
$this->_parser = xml_parser_create_ns('UTF-8');
// forget old data...
@@ -1401,22 +1401,48 @@ private function get_respond() {
// check for a specified content-length
case preg_match('/Content\\-Length:\\s+([0-9]*)\\r\\n/',$header,$matches):
$this->_error_log('Getting data using Content-Length '. $matches[1]);
+
// check if we the content data size is small enough to get it as one block
if ($matches[1] <= $max_chunk_size ) {
// only read something if Content-Length is bigger than 0
if ($matches[1] > 0 ) {
$buffer = fread($this->sock, $matches[1]);
+ $loadsize = strlen($buffer);
+ //did we realy get the full length?
+ if ($loadsize < $matches[1]) {
+ $max_chunk_size = $loadsize;
+ do {
+ $mod = $max_chunk_size % ($matches[1] - strlen($buffer));
+ $chunk_size = ($mod == $max_chunk_size ? $max_chunk_size : $matches[1] - strlen($buffer));
+ $buffer .= fread($this->sock, $chunk_size);
+ $this->_error_log('mod: ' . $mod . ' chunk: ' . $chunk_size . ' total: ' . strlen($buffer));
+ } while ($mod == $max_chunk_size);
+ break;
+ } else {
+ break;
+ }
} else {
$buffer = '';
+ break;
}
- } else {
- // data is to big to handle it as one. Get it chunk per chunk...
- do {
- $mod = $max_chunk_size % ($matches[1] - strlen($buffer));
- $chunk_size = ($mod == $max_chunk_size ? $max_chunk_size : $matches[1] - strlen($buffer));
- $buffer .= fread($this->sock, $chunk_size);
- $this->_error_log('mod: ' . $mod . ' chunk: ' . $chunk_size . ' total: ' . strlen($buffer));
- } while ($mod == $max_chunk_size);
+ }
+
+ // data is to big to handle it as one. Get it chunk per chunk...
+ //trying to get the full length of max_chunk_size
+ $buffer = fread($this->sock, $max_chunk_size);
+ $loadsize = strlen($buffer);
+ if ($loadsize < $max_chunk_size) {
+ $max_chunk_size = $loadsize;
+ }
+ do {
+ $mod = $max_chunk_size % ($matches[1] - strlen($buffer));
+ $chunk_size = ($mod == $max_chunk_size ? $max_chunk_size : $matches[1] - strlen($buffer));
+ $buffer .= fread($this->sock, $chunk_size);
+ $this->_error_log('mod: ' . $mod . ' chunk: ' . $chunk_size . ' total: ' . strlen($buffer));
+ } while ($mod == $max_chunk_size);
+ $loadsize = strlen($buffer);
+ if ($loadsize < $matches[1]) {
+ $buffer .= fread($this->sock, $matches[1] - $loadsize);
}
break;
3  repository/webdav/lib.php
View
@@ -118,7 +118,7 @@ public function get_listing($path='', $page = '') {
}
if (!empty($v['resourcetype']) && $v['resourcetype'] == 'collection') {
// a folder
- if ($path != $v['href']) {
+ if (ltrim($path, '/') != ltrim($v['href'], '/')) {
$matches = array();
preg_match('#(\w+)$#i', $v['href'], $matches);
if (!empty($matches[1])) {
@@ -137,6 +137,7 @@ public function get_listing($path='', $page = '') {
}
}else{
// a file
+ $path = rtrim($path,'/');
$title = urldecode(substr($v['href'], strpos($v['href'], $path)+strlen($path)));
$title = basename($title);
$size = !empty($v['getcontentlength'])? $v['getcontentlength']:'';
Please sign in to comment.
Something went wrong with that request. Please try again.