Add BeforePageRedirect hook to OutputPage, allowing extensions to override redirect...
[lhc/web/wiklou.git] / includes / HttpFunctions.php
index 6968c61..f25a806 100644 (file)
@@ -29,6 +29,8 @@ class Http {
         *    - followRedirects     Whether to follow redirects (defaults to false).
         *                                  Note: this should only be used when the target URL is trusted,
         *                                  to avoid attacks on intranet services accessible by HTTP.
+        *    - userAgent           A user agent, if you want to override the default
+        *                          MediaWiki/$wgVersion
         * @return Mixed: (bool)false on failure or a string on success
         */
        public static function request( $method, $url, $options = array() ) {
@@ -40,6 +42,9 @@ class Http {
                }
 
                $req = MWHttpRequest::factory( $url, $options );
+               if( isset( $options['userAgent'] ) ) {
+                       $req->setUserAgent( $options['userAgent'] );
+               }
                $status = $req->execute();
 
                if ( $status->isOK() ) {
@@ -129,6 +134,8 @@ class Http {
         * protocols, because we only want protocols that both cURL
         * and php support.
         *
+        * file:// should not be allowed here for security purpose (r67684)
+        *
         * @fixme this is wildly inaccurate and fails to actually check most stuff
         *
         * @param $uri Mixed: URI to check for validity
@@ -855,7 +862,7 @@ class PhpHttpRequest extends MWHttpRequest {
                        # Check security of URL
                        $url = $this->getResponseHeader( "Location" );
 
-                       if ( !HTTP::isValidURI( $url ) ) {
+                       if ( !Http::isValidURI( $url ) ) {
                                wfDebug( __METHOD__ . ": insecure redirection\n" );
                                break;
                        }