r89848 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89847‎ | r89848 | r89849 >
Date:20:08, 10 June 2011
Author:krinkle
Status:ok (Comments)
Tags:
Comment:
Follow-up: r89845: Forgot to commit changes in the other directory
Modified paths:
  • /trunk/phase3/resources/mediawiki.util/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.util/mediawiki.util.js
@@ -560,7 +560,7 @@
561561 var block = allowBlock ? '(?:\\/(?:3[0-2]|[12]?\\d))?' : '';
562562 var RE_IP_BYTE = '(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])';
563563 var RE_IP_ADD = '(?:' + RE_IP_BYTE + '\\.){3}' + RE_IP_BYTE;
564 - return address.search( new RegExp( '^' + RE_IP_ADD + block + '$' ) ) != -1;
 564+ return typeof address === 'string' && address.search( new RegExp( '^' + RE_IP_ADD + block + '$' ) ) != -1;
565565 },
566566 /**
567567 * Note: borrows from IP::isIPv6
@@ -570,6 +570,9 @@
571571 * @return boolean
572572 */
573573 'isIPv6Address' : function( address, allowBlock ) {
 574+ if ( typeof address !== 'string' ) {
 575+ return false;
 576+ }
574577 var block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '';
575578 var RE_IPV6_ADD =
576579 '(?:' + // starts with "::" (including "::")

Follow-up revisions

RevisionCommit summaryAuthorDate
r93805Follows-up r89848 CR: Cleaner solutionkrinkle07:45, 3 August 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89845Review of unit test suites...krinkle19:55, 10 June 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   20:36, 21 June 2011

Can just put the if ( typeof address !== 'string' ) check at the top of the ipv4 function?

#Comment by Krinkle (talk | contribs)   07:46, 3 August 2011

Done in r93805.

Status & tagging log