http://www.mediawiki.org/wiki/Special:Code/MediaWiki/95653

Revision: 95653
Author:   catrope
Date:     2011-08-29 09:17:54 +0000 (Mon, 29 Aug 2011)
Log Message:
-----------
Protocol-relative URL fixes for Collection:
* Expand URLs that are being used to redirect in non-standard ways (directly 
fed to Location:, or via JS) to the current protocol
* Use canonical URLs in metadata
* Expand $wgScriptPath to the canonical protocol when passing it to the 
backend. Christoph (PediaPress) tells me the backend can handle HTTPS URLs
* Expand download URL in interface template to current protocol
* Expand HTTP referer URL to current protocol

Modified Paths:
--------------
    trunk/extensions/Collection/Collection.body.php
    trunk/extensions/Collection/Collection.php

Modified: trunk/extensions/Collection/Collection.body.php
===================================================================
--- trunk/extensions/Collection/Collection.body.php     2011-08-29 09:00:39 UTC 
(rev 95652)
+++ trunk/extensions/Collection/Collection.body.php     2011-08-29 09:17:54 UTC 
(rev 95653)
@@ -574,7 +574,7 @@
                        'revision' => strval( $oldid ),
                        'latest' => strval( $latest ),
                        'timestamp' => wfTimestamp( TS_UNIX, 
$revision->mTimestamp ),
-                       'url' => $title->getFullURL(),
+                       'url' => $title->getCanonicalURL(),
                        'currentVersion' => $currentVersion,
                );
 
@@ -764,7 +764,7 @@
                                'latest' => $latest,
                                'revision' => $oldid,
                                'timestamp' => wfTimestamp( TS_UNIX, 
$revision->mTimestamp ),
-                               'url' => $articleTitle->getFullURL(),
+                               'url' => $articleTitle->getCanonicalURL(),
                                'currentVersion' => $currentVersion,
                        );
                        if ( $displayTitle ) {
@@ -959,7 +959,7 @@
 
                $response = self::mwServeCommand( 'render', array(
                        'metabook' => $this->buildJSONCollection( $collection ),
-                       'base_url' => wfExpandUrl( $wgScriptPath ),
+                       'base_url' => wfExpandUrl( $wgScriptPath, 
PROTO_CANONICAL ),
                        'script_extension' => $wgScriptExtension,
                        'template_blacklist' => wfMsgForContent( 
'coll-template_blacklist_title' ),
                        'template_exclusion_category' => wfMsgForContent( 
'coll-exclusion_category_title' ),
@@ -992,7 +992,7 @@
 
                $response = self::mwServeCommand( 'render', array(
                        'collection_id' => $collectionID,
-                       'base_url' => wfExpandUrl( $wgScriptPath ),
+                       'base_url' => wfExpandUrl( $wgScriptPath, 
PROTO_CANONICAL ),
                        'script_extension' => $wgScriptExtension,
                        'template_blacklist' => wfMsgForContent( 
'coll-template_blacklist_title' ),
                        'template_exclusion_category' => wfMsgForContent( 
'coll-exclusion_category_title' ),
@@ -1067,7 +1067,7 @@
                        $wgOut->setPageTitle( wfMsg( 
'coll-rendering_finished_title' ) );
 
                        $template = new CollectionFinishedTemplate();
-                       $template->set( 'download_url', wfExpandUrl( 
SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ) ) );
+                       $template->set( 'download_url', wfExpandUrl( 
SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ), 
PROTO_CURRENT ) );
                        $template->set( 'is_cached', $wgRequest->getVal( 
'is_cached' ) );
                        $template->set( 'query', $query );
                        $template->set( 'return_to', $return_to );
@@ -1163,7 +1163,7 @@
 
                $response = self::mwServeCommand( 'zip_post', array(
                        'metabook' => $this->buildJSONCollection( $collection ),
-                       'base_url' => wfExpandUrl( $wgScriptPath ),
+                       'base_url' => wfExpandUrl( $wgScriptPath, 
PROTO_CANONICAL ),
                        'script_extension' => $wgScriptExtension,
                        'template_blacklist' => wfMsgForContent( 
'coll-template_blacklist_title' ),
                        'template_exclusion_category' => wfMsgForContent( 
'coll-exclusion_category_title' ),
@@ -1284,7 +1284,7 @@
                curl_setopt( $c, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
                curl_setopt( $c, CURLOPT_HEADER, false );
                if ( is_object( $wgTitle ) ) {
-                       curl_setopt( $c, CURLOPT_REFERER, 
$wgTitle->getFullURL() );
+                       curl_setopt( $c, CURLOPT_REFERER, wfExpandUrl( 
$wgTitle->getFullURL(), PROTO_CURRENT ) );
                }
                if ( $timeout ) {
                        curl_setopt( $c, CURLOPT_TIMEOUT, $wgHTTPTimeout );

Modified: trunk/extensions/Collection/Collection.php
===================================================================
--- trunk/extensions/Collection/Collection.php  2011-08-29 09:00:39 UTC (rev 
95652)
+++ trunk/extensions/Collection/Collection.php  2011-08-29 09:17:54 UTC (rev 
95653)
@@ -216,12 +216,12 @@
        $r = new AjaxResponse();
        if ( $redirect ) {
                $title = Title::newFromText( $redirect );
-               $redirecturl = $title->getFullURL();
+               $redirecturl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT 
);
                $r->setResponseCode( 302 );
                header( 'Location: ' . $redirecturl );
        } else {
                $title = SpecialPage::getTitleFor( 'Book' );
-               $redirecturl = $title->getFullURL();
+               $redirecturl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT 
);
                $r->setContentType( 'application/json' );
                $r->addText( $json->encode( array( 'redirect_url' => 
$redirecturl ) ) );
        }


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to