r110340 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110339‎ | r110340 | r110341 >
Date:23:07, 30 January 2012
Author:mah
Status:reverted (Comments)
Tags:
Comment:
Fixes bug 34036 - [regression] mw.loader.load doesn't works as importScriptURI for some kinds of URLs
Patch from Helder.wiki
Modified paths:
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -1137,7 +1137,7 @@
11381138 * "text/javascript"; if no type is provided, text/javascript is assumed.
11391139 */
11401140 load: function ( modules, type ) {
1141 - var filtered, m;
 1141+ var filtered, m, reValidURL;
11421142
11431143 // Validate input
11441144 if ( typeof modules !== 'object' && typeof modules !== 'string' ) {
@@ -1146,7 +1146,8 @@
11471147 // Allow calling with an external url or single dependency as a string
11481148 if ( typeof modules === 'string' ) {
11491149 // Support adding arbitrary external scripts
1150 - if ( /^(https?:)?\/\//.test( modules ) ) {
 1150+ reValidURL = new RegExp( '^((https?:)?\\/\\/|' + $.escapeRE( mw.config.get( 'wgScript' ) ) + ')' );
 1151+ if ( reValidURL.test( modules ) ) {
11511152 if ( type === 'text/css' ) {
11521153 $( 'head' ).append( $( '<link>', {
11531154 rel: 'stylesheet',

Follow-up revisions

RevisionCommit summaryAuthorDate
r110351revert r110340 after talking with krinlemah01:02, 31 January 2012

Comments

#Comment by Krinkle (talk | contribs)   23:16, 30 January 2012

As documented, mw.loader.load takes one or more module names or a full url. Relative paths are not accepted.

Adding an exception in the protocol regex for one particular file in the root (index.php) makes no sense. What about the API, or uploads, or files in extension paths ? No need to add all these.

importScriptURI is not exactly the same as mw.loader.load. If and when a user decides to change one for the other, the url should be make complete. So in the case of calls to index.php, wgServer needs to be prefixed.

Status & tagging log