summaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/ajax/newfile.php9
1 files changed, 7 insertions, 2 deletions
diff --git a/apps/files/ajax/newfile.php b/apps/files/ajax/newfile.php
index 46629e1b602..392fc5bd1c8 100644
--- a/apps/files/ajax/newfile.php
+++ b/apps/files/ajax/newfile.php
@@ -46,6 +46,7 @@ function progress($notification_code, $severity, $message, $message_code, $bytes
}
}
+
$l10n = \OC::$server->getL10N('files');
$result = array(
@@ -93,7 +94,8 @@ if (\OC\Files\Filesystem::file_exists($target)) {
}
if($source) {
- if(substr($source, 0, 8)!='https://' and substr($source, 0, 7)!='http://') {
+ $httpHelper = \OC::$server->getHTTPHelper();
+ if(!$httpHelper->isHTTPURL($source)) {
OCP\JSON::error(array('data' => array('message' => $l10n->t('Not a valid source'))));
exit();
}
@@ -104,7 +106,10 @@ if($source) {
exit();
}
- $ctx = stream_context_create(null, array('notification' =>'progress'));
+ $source = $httpHelper->getFinalLocationOfURL($source);
+
+ $ctx = stream_context_create(\OC::$server->getHTTPHelper()->getDefaultContextArray(), array('notification' =>'progress'));
+
$sourceStream=@fopen($source, 'rb', false, $ctx);
$result = 0;
if (is_resource($sourceStream)) {