r95653 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95652‎ | r95653 | r95654 >
Date:09:17, 29 August 2011
Author:catrope
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/Collection/Collection.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/Collection.body.php
@@ -574,7 +574,7 @@
575575 'revision' => strval( $oldid ),
576576 'latest' => strval( $latest ),
577577 'timestamp' => wfTimestamp( TS_UNIX, $revision->mTimestamp ),
578 - 'url' => $title->getFullURL(),
 578+ 'url' => $title->getCanonicalURL(),
579579 'currentVersion' => $currentVersion,
580580 );
581581
@@ -764,7 +764,7 @@
765765 'latest' => $latest,
766766 'revision' => $oldid,
767767 'timestamp' => wfTimestamp( TS_UNIX, $revision->mTimestamp ),
768 - 'url' => $articleTitle->getFullURL(),
 768+ 'url' => $articleTitle->getCanonicalURL(),
769769 'currentVersion' => $currentVersion,
770770 );
771771 if ( $displayTitle ) {
@@ -959,7 +959,7 @@
960960
961961 $response = self::mwServeCommand( 'render', array(
962962 'metabook' => $this->buildJSONCollection( $collection ),
963 - 'base_url' => wfExpandUrl( $wgScriptPath ),
 963+ 'base_url' => wfExpandUrl( $wgScriptPath, PROTO_CANONICAL ),
964964 'script_extension' => $wgScriptExtension,
965965 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
966966 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
@@ -992,7 +992,7 @@
993993
994994 $response = self::mwServeCommand( 'render', array(
995995 'collection_id' => $collectionID,
996 - 'base_url' => wfExpandUrl( $wgScriptPath ),
 996+ 'base_url' => wfExpandUrl( $wgScriptPath, PROTO_CANONICAL ),
997997 'script_extension' => $wgScriptExtension,
998998 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
999999 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
@@ -1067,7 +1067,7 @@
10681068 $wgOut->setPageTitle( wfMsg( 'coll-rendering_finished_title' ) );
10691069
10701070 $template = new CollectionFinishedTemplate();
1071 - $template->set( 'download_url', wfExpandUrl( SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ) ) );
 1071+ $template->set( 'download_url', wfExpandUrl( SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ), PROTO_CURRENT ) );
10721072 $template->set( 'is_cached', $wgRequest->getVal( 'is_cached' ) );
10731073 $template->set( 'query', $query );
10741074 $template->set( 'return_to', $return_to );
@@ -1163,7 +1163,7 @@
11641164
11651165 $response = self::mwServeCommand( 'zip_post', array(
11661166 'metabook' => $this->buildJSONCollection( $collection ),
1167 - 'base_url' => wfExpandUrl( $wgScriptPath ),
 1167+ 'base_url' => wfExpandUrl( $wgScriptPath, PROTO_CANONICAL ),
11681168 'script_extension' => $wgScriptExtension,
11691169 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
11701170 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
@@ -1284,7 +1284,7 @@
12851285 curl_setopt( $c, CURLOPT_HTTPHEADER, array( 'Expect:' ) );
12861286 curl_setopt( $c, CURLOPT_HEADER, false );
12871287 if ( is_object( $wgTitle ) ) {
1288 - curl_setopt( $c, CURLOPT_REFERER, $wgTitle->getFullURL() );
 1288+ curl_setopt( $c, CURLOPT_REFERER, wfExpandUrl( $wgTitle->getFullURL(), PROTO_CURRENT ) );
12891289 }
12901290 if ( $timeout ) {
12911291 curl_setopt( $c, CURLOPT_TIMEOUT, $wgHTTPTimeout );
Index: trunk/extensions/Collection/Collection.php
@@ -216,12 +216,12 @@
217217 $r = new AjaxResponse();
218218 if ( $redirect ) {
219219 $title = Title::newFromText( $redirect );
220 - $redirecturl = $title->getFullURL();
 220+ $redirecturl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
221221 $r->setResponseCode( 302 );
222222 header( 'Location: ' . $redirecturl );
223223 } else {
224224 $title = SpecialPage::getTitleFor( 'Book' );
225 - $redirecturl = $title->getFullURL();
 225+ $redirecturl = wfExpandUrl( $title->getFullURL(), PROTO_CURRENT );
226226 $r->setContentType( 'application/json' );
227227 $r->addText( $json->encode( array( 'redirect_url' => $redirecturl ) ) );
228228 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r959011.17wmf1: MFT HTTPS / prot rel URL fixes: r95627, r95651, r95652, r95653, r95...catrope19:15, 31 August 2011
r96286Fix r95653: as reported on bug 30680, this broke Collection. Expanding $wgScr...catrope16:06, 5 September 2011
r964851.18: MFT protocol-relative URL saga: r95014, r95016, r95017, r95627, r95651,...catrope20:14, 7 September 2011

Status & tagging log