summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/HTTPClient.php10
-rw-r--r--inc/io.php4
2 files changed, 11 insertions, 3 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 69a384487..1612f1211 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -227,9 +227,17 @@ class HTTPClient {
$r_headers .= fread($socket,1); #FIXME read full lines here?
}while(!preg_match('/\r\n\r\n$/',$r_headers));
+ // check if expected body size exceeds allowance
+ if($this->max_bodysize && preg_match('/\r\nContent-Length:\s*(\d+)\r\n/i',$r_header,$match)){
+ if($match[1] > $this->max_bodysize){
+ $this->error = 'Reported content length exceeds allowed response size';
+ return false;
+ }
+ }
+
//read body (with chunked encoding if needed)
$r_body = '';
- if(preg_match('/transfer\-(en)?coding:\s+chunked\r\n/i',$r_header)){
+ if(preg_match('/transfer\-(en)?coding:\s*chunked\r\n/i',$r_header)){
do {
unset($chunk_size);
do {
diff --git a/inc/io.php b/inc/io.php
index ea20502bb..aed27d88e 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -292,10 +292,10 @@ function io_mkdir_ftp($dir){
* @author Andreas Gohr <andi@splitbrain.org>
* @author Chris Smith <chris@jalakai.co.uk>
*/
-function io_download($url,$file,$useAttachment=false,$defaultName=''){
+function io_download($url,$file,$useAttachment=false,$defaultName='',$maxSize=2097152){
global $conf;
$http = new DokuHTTPClient();
- $http->max_bodysize = 2*1024*1024; //max. 2MB
+ $http->max_bodysize = $maxSize;
$http->timeout = 25; //max. 25 sec
$data = $http->get($url);