Bartosz Dziewoński has uploaded a new change for review. https://gerrit.wikimedia.org/r/257214
Change subject: core.js: Deindent large chunk of the file ...................................................................... core.js: Deindent large chunk of the file Several functions were unnecessarily placed in a closure meant to wrap only the definition of OO.ui.msg. Change-Id: I888952a4ec033602788d8e3416c7fed0c4f10263 --- M src/core.js 1 file changed, 59 insertions(+), 60 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/14/257214/1 diff --git a/src/core.js b/src/core.js index 8c8dbb5..7ad4a3a 100644 --- a/src/core.js +++ b/src/core.js @@ -355,64 +355,63 @@ } return message; }; - - /** - * Package a message and arguments for deferred resolution. - * - * Use this when you are statically specifying a message and the message may not yet be present. - * - * @param {string} key Message key - * @param {Mixed...} [params] Message parameters - * @return {Function} Function that returns the resolved message when executed - */ - OO.ui.deferMsg = function () { - var args = arguments; - return function () { - return OO.ui.msg.apply( OO.ui, args ); - }; - }; - - /** - * Resolve a message. - * - * If the message is a function it will be executed, otherwise it will pass through directly. - * - * @param {Function|string} msg Deferred message, or message text - * @return {string} Resolved message - */ - OO.ui.resolveMsg = function ( msg ) { - if ( $.isFunction( msg ) ) { - return msg(); - } - return msg; - }; - - /** - * @param {string} url - * @return {boolean} - */ - OO.ui.isSafeUrl = function ( url ) { - var protocol, - // Keep in sync with php/Tag.php - whitelist = [ - 'bitcoin:', 'ftp:', 'ftps:', 'geo:', 'git:', 'gopher:', 'http:', 'https:', 'irc:', 'ircs:', - 'magnet:', 'mailto:', 'mms:', 'news:', 'nntp:', 'redis:', 'sftp:', 'sip:', 'sips:', 'sms:', 'ssh:', - 'svn:', 'tel:', 'telnet:', 'urn:', 'worldwind:', 'xmpp:' - ]; - - if ( url.indexOf( ':' ) === -1 ) { - // No protocol, safe - return true; - } - - protocol = url.split( ':', 1 )[ 0 ] + ':'; - if ( !protocol.match( /^([A-za-z0-9\+\.\-])+:/ ) ) { - // Not a valid protocol, safe - return true; - } - - // Safe if in the whitelist - return whitelist.indexOf( protocol ) !== -1; - }; - } )(); + +/** + * Package a message and arguments for deferred resolution. + * + * Use this when you are statically specifying a message and the message may not yet be present. + * + * @param {string} key Message key + * @param {Mixed...} [params] Message parameters + * @return {Function} Function that returns the resolved message when executed + */ +OO.ui.deferMsg = function () { + var args = arguments; + return function () { + return OO.ui.msg.apply( OO.ui, args ); + }; +}; + +/** + * Resolve a message. + * + * If the message is a function it will be executed, otherwise it will pass through directly. + * + * @param {Function|string} msg Deferred message, or message text + * @return {string} Resolved message + */ +OO.ui.resolveMsg = function ( msg ) { + if ( $.isFunction( msg ) ) { + return msg(); + } + return msg; +}; + +/** + * @param {string} url + * @return {boolean} + */ +OO.ui.isSafeUrl = function ( url ) { + var protocol, + // Keep in sync with php/Tag.php + whitelist = [ + 'bitcoin:', 'ftp:', 'ftps:', 'geo:', 'git:', 'gopher:', 'http:', 'https:', 'irc:', 'ircs:', + 'magnet:', 'mailto:', 'mms:', 'news:', 'nntp:', 'redis:', 'sftp:', 'sip:', 'sips:', 'sms:', 'ssh:', + 'svn:', 'tel:', 'telnet:', 'urn:', 'worldwind:', 'xmpp:' + ]; + + if ( url.indexOf( ':' ) === -1 ) { + // No protocol, safe + return true; + } + + protocol = url.split( ':', 1 )[ 0 ] + ':'; + if ( !protocol.match( /^([A-za-z0-9\+\.\-])+:/ ) ) { + // Not a valid protocol, safe + return true; + } + + // Safe if in the whitelist + return whitelist.indexOf( protocol ) !== -1; +}; -- To view, visit https://gerrit.wikimedia.org/r/257214 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I888952a4ec033602788d8e3416c7fed0c4f10263 Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits