]> source.dussan.org Git - nextcloud-server.git/commitdiff
Verify whether the URL is valid
authorLukas Reschke <lukas@owncloud.org>
Sun, 27 Jul 2014 14:46:32 +0000 (16:46 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 28 Jul 2014 09:08:15 +0000 (11:08 +0200)
Required for https://github.com/owncloud/mail/pull/100#issuecomment-50266017

@karlitschek Backport for stable6 and stable7 requested.

lib/private/util.php

index eea194288f952ba8c7034ba4457cdb53a08ef47f..67da7a2f63f6df2eacd5020f0bddc7a3e7ec7717 100755 (executable)
@@ -1217,11 +1217,16 @@ class OC_Util {
        /**
         * @Brief Get file content via curl.
         * @param string $url Url to get content
+        * @throws Exception If the URL does not start with http:// or https://
         * @return string of the response or false on error
         * This function get the content of a page via curl, if curl is enabled.
         * If not, file_get_contents is used.
         */
        public static function getUrlContent($url) {
+               if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
+                       throw new Exception('$url must start with https:// or http://', 1);
+               }
+               
                if (function_exists('curl_init')) {
                        $curl = curl_init();
                        $max_redirects = 10;