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

Revision: 96560
Author:   catrope
Date:     2011-09-08 12:59:19 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
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
    trunk/extensions/OggHandler/OggPlayer.js

Modified: trunk/extensions/OggHandler/OggHandler_body.php
===================================================================
--- trunk/extensions/OggHandler/OggHandler_body.php     2011-09-08 12:49:01 UTC 
(rev 96559)
+++ trunk/extensions/OggHandler/OggHandler_body.php     2011-09-08 12:59:19 UTC 
(rev 96560)
@@ -443,12 +443,12 @@
        }
 
        static function getMyScriptPath() {
-               global $wgScriptPath;
-               return "$wgScriptPath/extensions/OggHandler";
+               global $wgExtensionAssetsPath;
+               return "$wgExtensionAssetsPath/OggHandler";
        }
 
        function setHeaders( $out ) {
-               global $wgOggScriptVersion, $wgCortadoJarFile, $wgServer;
+               global $wgOggScriptVersion, $wgCortadoJarFile;
 
                if ( $out->hasHeadItem( 'OggHandlerScript' ) && 
$out->hasHeadItem( 'OggHandlerInlineScript' ) &&
                        $out->hasHeadItem( 'OggHandlerInlineCSS' ) ) {
@@ -466,8 +466,9 @@
                $cortadoUrl = $wgCortadoJarFile;
                $scriptPath = self::getMyScriptPath();
                if( substr( $cortadoUrl, 0, 1 ) != '/'
-                       && substr( $cortadoUrl, 0, 4 ) != 'http' ) {
-                       $cortadoUrl = "$wgServer$scriptPath/$cortadoUrl";
+                               && substr( $cortadoUrl, 0, 4 ) != 'http' )
+               {
+                       $cortadoUrl = wfExpandUrl( "$scriptPath/$cortadoUrl", 
PROTO_CURRENT );
                }
                $encCortadoUrl = Xml::encodeJsVar( $cortadoUrl );
                $encExtPathUrl = Xml::encodeJsVar( $scriptPath );
@@ -540,12 +541,7 @@
 
                OggTransformOutput::$serial++;
 
-               if ( substr( $this->videoUrl, 0, 4 ) != 'http' ) {
-                       global $wgServer;
-                       $url = $wgServer . $this->videoUrl;
-               } else {
-                       $url = $this->videoUrl;
-               }
+               $url = wfExpandUrl( $this->videoUrl, PROTO_RELATIVE );
                // Normalize values
                $length = floatval( $this->length );
                $width = intval( $this->width );

Modified: trunk/extensions/OggHandler/OggPlayer.js
===================================================================
--- trunk/extensions/OggHandler/OggPlayer.js    2011-09-08 12:49:01 UTC (rev 
96559)
+++ trunk/extensions/OggHandler/OggPlayer.js    2011-09-08 12:59:19 UTC (rev 
96560)
@@ -51,6 +51,11 @@
         * Parameters are: id, videoUrl, width, height, length, linkUrl, isVideo
         */
        'init': function ( player, params ) {
+               // Expand params.videoUrl if protocol-relative
+               if ( params.videoUrl.substr( 0, 2 ) == '//' ) {
+                       // window.location.protocol is something like 'http:'
+                       params.videoUrl = window.location.protocol + 
params.videoUrl;
+               }
                elt = document.getElementById( params.id );
 
                // Save still image HTML


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

Reply via email to