r96560 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96559‎ | r96560 | r96561 >
Date:12:59, 8 September 2011
Author:catrope
Status:ok
Tags:
Comment:
OggHandler: Address issues with protocol-relative URLs. Live hack in r96400.
* Use $wgExtensionAssetsPath instead of "$wgScriptPath/extensions"
* Use wfExpandUrl() rather than the DIY method of detecting whether the URL needs expanding and prepending $wgServer. Left the detection for $wgCortadoJarFile alone since that needs $scriptPath prepended to it if it's not absolute
* Expand $this->videoUrl using PROTO_RELATIVE instead of r96400 's PROTO_CURRENT to avoid cache pollution, and add a protocol the second the URL arrives on the JS side
Modified paths:
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /trunk/extensions/OggHandler/OggPlayer.js (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggPlayer.js
@@ -51,6 +51,11 @@
5252 * Parameters are: id, videoUrl, width, height, length, linkUrl, isVideo
5353 */
5454 'init': function ( player, params ) {
 55+ // Expand params.videoUrl if protocol-relative
 56+ if ( params.videoUrl.substr( 0, 2 ) == '//' ) {
 57+ // window.location.protocol is something like 'http:'
 58+ params.videoUrl = window.location.protocol + params.videoUrl;
 59+ }
5560 elt = document.getElementById( params.id );
5661
5762 // Save still image HTML
Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -443,12 +443,12 @@
444444 }
445445
446446 static function getMyScriptPath() {
447 - global $wgScriptPath;
448 - return "$wgScriptPath/extensions/OggHandler";
 447+ global $wgExtensionAssetsPath;
 448+ return "$wgExtensionAssetsPath/OggHandler";
449449 }
450450
451451 function setHeaders( $out ) {
452 - global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer;
 452+ global $wgOggScriptVersion, $wgCortadoJarFile;
453453
454454 if ( $out->hasHeadItem( 'OggHandlerScript' ) && $out->hasHeadItem( 'OggHandlerInlineScript' ) &&
455455 $out->hasHeadItem( 'OggHandlerInlineCSS' ) ) {
@@ -466,8 +466,9 @@
467467 $cortadoUrl = $wgCortadoJarFile;
468468 $scriptPath = self::getMyScriptPath();
469469 if( substr( $cortadoUrl, 0, 1 ) != '/'
470 - && substr( $cortadoUrl, 0, 4 ) != 'http' ) {
471 - $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl";
 470+ && substr( $cortadoUrl, 0, 4 ) != 'http' )
 471+ {
 472+ $cortadoUrl = wfExpandUrl( "$scriptPath/$cortadoUrl", PROTO_CURRENT );
472473 }
473474 $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl );
474475 $encExtPathUrl = Xml::encodeJsVar( $scriptPath );
@@ -540,12 +541,7 @@
541542
542543 OggTransformOutput::$serial++;
543544
544 - if ( substr( $this->videoUrl, 0, 4 ) != 'http' ) {
545 - global $wgServer;
546 - $url = $wgServer . $this->videoUrl;
547 - } else {
548 - $url = $this->videoUrl;
549 - }
 545+ $url = wfExpandUrl( $this->videoUrl, PROTO_RELATIVE );
550546 // Normalize values
551547 $length = floatval( $this->length );
552548 $width = intval( $this->width );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97272REL1_18 MFT r96560, r96630reedy14:17, 16 September 2011
r972891.17wmf1 Revert r96400, MFT r96560reedy15:17, 16 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96400Fix for total extension breakage due to protocol relative URLststarling02:57, 7 September 2011

Status & tagging log