summaryrefslogtreecommitdiffstats
path: root/lib/helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helper.php')
-rw-r--r--lib/helper.php36
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/helper.php b/lib/helper.php
index a0fbdd10394..41985ca57a7 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -132,7 +132,8 @@ class OC_Helper {
* Returns a absolute url to the given service.
*/
public static function linkToRemote( $service, $add_slash = true ) {
- return self::makeURLAbsolute(self::linkToRemoteBase($service)) . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
+ return self::makeURLAbsolute(self::linkToRemoteBase($service))
+ . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
}
/**
@@ -144,7 +145,8 @@ class OC_Helper {
* Returns a absolute url to the given service.
*/
public static function linkToPublic($service, $add_slash = false) {
- return self::linkToAbsolute( '', 'public.php') . '?service=' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
+ return self::linkToAbsolute( '', 'public.php') . '?service=' . $service
+ . (($add_slash && $service[strlen($service)-1]!='/')?'/':'');
}
/**
@@ -379,7 +381,8 @@ class OC_Helper {
$mimeType='application/octet-stream';
}
- if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) {
+ if($mimeType=='application/octet-stream' and function_exists('finfo_open')
+ and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) {
$info = @strtolower(finfo_file($finfo, $path));
if($info) {
$mimeType=substr($info, 0, strpos($info, ';'));
@@ -436,14 +439,16 @@ class OC_Helper {
//FIXME: should also check for value validation (i.e. the email is an email).
public static function init_var($s, $d="") {
$r = $d;
- if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s]))
- $r = stripslashes(htmlspecialchars($_REQUEST[$s]));
+ if(isset($_REQUEST[$s]) && !empty($_REQUEST[$s])) {
+ $r = OC_Util::sanitizeHTML($_REQUEST[$s]);
+ }
return $r;
}
/**
- * returns "checked"-attribute if request contains selected radio element OR if radio element is the default one -- maybe?
+ * returns "checked"-attribute if request contains selected radio element
+ * OR if radio element is the default one -- maybe?
* @param string $s Name of radio-button element name
* @param string $v Value of current radio-button element
* @param string $d Value of default radio-button element
@@ -508,11 +513,16 @@ class OC_Helper {
if(!$source or !$target) {
return false;
}
- $count=0;
+ $result = true;
+ $count = 0;
while(!feof($source)) {
- $count+=fwrite($target, fread($source, 8192));
+ if ( ( $c = fwrite($target, fread($source, 8192)) ) === false) {
+ $result = false;
+ } else {
+ $count += $c;
+ }
}
- return $count;
+ return array($count, $result);
}
/**
@@ -757,9 +767,13 @@ class OC_Helper {
$maxUploadFilesize = min($upload_max_filesize, $post_max_size);
$freeSpace = \OC\Files\Filesystem::free_space($dir);
- $freeSpace = max($freeSpace, 0);
+ if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){
+ $freeSpace = max($freeSpace, 0);
- return min($maxUploadFilesize, $freeSpace);
+ return min($maxUploadFilesize, $freeSpace);
+ } else {
+ return $maxUploadFilesize;
+ }
}
/**