Commit graph

103 commits

Author SHA1 Message Date
Aaron Schulz
2d56adb393 Simplified IPv6 regex per comment
* We already require PHP 5.3.2, which includes PCRE 7.2+.
  PHP 5.2.4 includes PCRE 7.2 per http://php.net/ChangeLog-5.php.

Change-Id: Ie9c1a0a93bef30a3a67e0140e621814351f8cea1
2013-10-14 19:02:38 +00:00
C. Scott Ananian
d0e8bde0a9 Minor bugfix to IP::prettifyIP.
The offset returned by preg_match with the PREG_OFFSET_CAPTURE is an
absolute position in the string.  You shouldn't *add* it to the
current position in order to advance past the match.

Change-Id: I3631c34e02d9b830bf841bf960855626fbc88eb0
2013-09-12 08:17:42 -07:00
MatmaRex
df8ec1e216 No spaces after (casts)
Also removed some unnecessary ones. I think I've caught them all.

The spaceless version already appears in core ~300 times (after
accounting for false positives when grepping). Some consistency would
be nice.

Change-Id: I607655b5f4366e66dc78730d5fd2f57ed8776cae
2013-09-04 20:05:43 +02:00
Mormegil
1437c25164 Improve behavior of IP::toUnsigned on Windows
On Windows (and 32-bit systems), pow( 2, 32 ) - 1 is a float, which makes
IP::toUnsigned return a float sometimes (instead of string, int, or false,
as is specified in the documentation).

This makes problems for some callers (e.g. I0c9a4ae7 had to modify
wfBaseConvert because of this, while I believe this change would have made
that change unnecessary).

So to improve that, and make the result correspond to the documentation,
we ensure floats are converted to strings.

Plus, more phpunit coverage of IP::toUnsigned and the related IP::toHex.

Change-Id: Ic8e4d9c65497e78960b03555eab0558a6af7d8d2
2013-06-25 20:04:46 +02:00
umherirrender
6f79eef473 Fixed spacing around parenthesis in includes
Change-Id: Ie8adc00f4ee8ecec4554e584c18d5d2073415397
2013-04-28 15:50:07 +00:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
umherirrender
d63121016d fix some spacing
Added/removed spaces around logical/arithmetic operator
Reduced multiple empty lines to one empty line
Removed wrong tabs before comments at end of line
Removed too many spaces in assigments

Change-Id: I2bba4e72f9b5f88c53324d7b70e6042f1aad8f6b
2013-03-07 17:53:21 +01:00
Antoine Musso
7006e1df93 style: fix up commas in function arguments
Fix up spaces in our function calls, we do not want spaces before a
comma and try to avoid multiple commas whenever possible.

Errors:

* No space found after comma in function call
* Space found before comma in function call

Change-Id: I51aec02016f742422fa60b92ad35ba3f0ef59ba3
2013-02-06 19:30:39 +01:00
Antoine Musso
9362bb6c56 miscellaneous doxygen warnings
* @licence -> @license
* Protects inline HTML by using double quotes, our inline comments uses
  elements such as <h1> or <firstnameLastname@gmail.com>
* Commands in lowercase (@TODO -> @todo, @NOTE -> @note)
* removes @abstract and @static since doxygen detects them from PHP
  code.
* various undocumented function parameters
* typos in parameters declarations

Change-Id: I62ad6fc124c355bf31acc780b9614a59cf79a421
2012-10-22 14:00:08 +02:00
daniel
5439012c36 [Bug 35738] remove zone info from ipv6 addresses
Patch provided by Nick Kuznia

Change-Id: Icccf10974746e8e27000ab45de28d0f1836ec8aa
2012-09-05 22:22:40 -07:00
Aaron
456177bdee [IP] Added an IP::prettifyIP() function for displaying IPs.
Change-Id: I53b3fe70bd0091ef02740f2b8950c36a0e4cf32e
2012-05-11 10:53:14 -07:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Antoine Musso
c1f23144e1 using real identity for hashar
Converting my pseudonym to use my real identity instead:
Ashar Voultoiz -> Antoine Musso
2011-10-24 09:08:13 +00:00
Aaron Schulz
c47386e27e Tweak r98602: keep the other IP normalization for non-ranges, such as upper case for v6. This keeps it a bit more consistent. 2011-10-01 05:11:21 +00:00
Aaron Schulz
9ac53dcc3b Made provideIPCIDRs() not add a '/' if there is no prefix length. Fixes bug 31234. 2011-10-01 04:54:44 +00:00
Aaron Schulz
1ec49ff3d3 Fixed typo in ipv6 private IP range list and added test (bug 30739) 2011-09-06 23:15:42 +00:00
Sam Reed
ad39f2da86 Trim trailing whitespace
Add/tweak/update documentation

Simplify some boolean returns
2011-09-04 21:40:17 +00:00
Tim Starling
6a2123260b * (bug 28798) Set $wgServer in the default LocalSettings.php
* (bug 14977) When detecting $wgServer, treat IPv6 addresses in $_SERVER['SERVER_NAME'] etc. in a sensible way. 
* Tests for the new functions in IP.php and Installer.php
2011-06-15 07:35:47 +00:00
Happy-melon
99f39a4779 Move Block::normaliseRange() to IP.php, then reduce it to 4 lines by using the existing functionality in that class. 2011-03-18 23:28:23 +00:00
Aaron Schulz
7fe32a2fa2 Follow-up r82093: fixed comment :) 2011-02-13 23:30:26 +00:00
Aaron Schulz
f65ce02ff9 * (bug 27353) IPv6 address ending in "::WORD" was not recognized
* Moved down 'contains no "::"' alternative for clarity (and possibly use frequency too)
* Added more IPv6 tests
2011-02-13 23:24:48 +00:00
Mark A. Hershberger
a465346c6e random w/s cleanup 2010-12-01 20:22:45 +00:00
Aaron Schulz
fb574da0ab *(bug 25920) Moved forward ref to a back ref to really get v6 regex to compile on older PCRE versions. Works around PCRE 8 nested named ref bug that killed r76928.
* Added another simple v6 assertion
2010-11-21 10:49:54 +00:00
Sam Reed
9a301f1636 Reverting r76928, causes segfault 2010-11-18 02:32:58 +00:00
Aaron Schulz
d0977b26a3 (bug 25920) Moved forward ref to a nested ref to really get v6 regex to compile on older PCRE versions 2010-11-18 00:25:58 +00:00
Aaron Schulz
52a79f37a1 * Reduced some pointless regex capture overhead
* Made preg_replace calls easier to verify w.r.t. captures
* (bug 25920) Made RE_IPV6_ADD avoid conditions on whether a named group matched anything, which requires PCRE 6.7+ (not bundled with PHP 5.1.0)
2010-11-17 09:12:18 +00:00
Alexandre Emsenhuber
386b748ca2 Fixed some doxygen warnings 2010-11-16 20:14:13 +00:00
Aaron Schulz
a34cccd8b1 Removed weird unused "IPv4toIPv6" function 2010-11-15 23:20:23 +00:00
Aaron Schulz
d7f0e354dd typo: RE_IPV4_BLOCK -> RE_IP_BLOCK 2010-11-15 20:37:11 +00:00
Aaron Schulz
3994a3b2e3 Minor cleanups 2010-11-13 23:31:13 +00:00
Aaron Schulz
21e317191b * parseCIDR() should use parseCIDR6() for IPv6 (plus the later is private since r76560...)
* Made parseRange() work for IPv6 "x - y" style ranges
* Added MWException to IPv4toIPv6()
2010-11-12 20:08:27 +00:00
Aaron Schulz
426f30bcfe * Removed redundant check in toUnsigned6().
* MW requires PHP 5.1+, so the -1/false ip2long annoyance is gone. Also, ip2long("255.255.255.255") is -1 so no special case code is needed anymore.
* Removed toSigned() (not used outside IP.php). Due to the above points, ip2long() is totally equilivant.
* Moved some functions and consts around.
* Comment tweaks.
2010-11-12 19:37:37 +00:00
Aaron Schulz
ff84f68f6a * Changes in IP.php:
** Fixed hexToOctet()/toOctet() padding (pad left not right)
** Made hexToQuad() left-pad input (e.g. C -> 0000000C)
** Added isPublic6() function (checked as needed by isPublic())
** Rewrote isValidBlock() to not do flaky and roundabout isArray() check. Works for v6 now.
** Removed toArray(), unused outside IP.php and broken for v6
** Removed toOctet() duplication
** Added new private IPv6ToRawHex() function. Used to make toHex() faster.
** Made some functions private
** Reverted r20435, pointless
** Updated credits
* Changes in IPTests:
** Added a bunch of tests (mostly v6)
** Removed weird array test (especially with toArray() gone) after r76514
** Padding *no* longer needed for hexToX functions - assertion flipped
* CheckUser: removed parseRange6() reference (now private)
2010-11-12 01:33:46 +00:00
Aaron Schulz
1a058cafed * Return type cleanup (int -> bool)
* Improved doc comments
2010-11-11 13:45:24 +00:00
Aaron Schulz
cd9108e37f * Followed-up r76267:
** Made RE_IPV6_ADD and sanitizeIP() hande '::'.
** RE_IPV6_ADD is no longer over-inclusive (# of octets and '::' must be valid)
* Removed weird debugging code
* Broke long line
2010-11-11 12:18:28 +00:00
Aaron Schulz
8090e523a2 Made sanitizeIP() handle CIDR IPs in IPv6 (fixes server-side stuff for bug 24293) 2010-11-07 21:53:26 +00:00
Aaron Schulz
521d3c4676 * Fixed RE_IPV6_ADD for IP networks ending in "::", like "abcd::/y" or "a::/y"
* Fixed formatHex() for IPv6 by handling prefix properly
* hextoOctet -> hexToOctet
* Assorted code cleanups (mostly with $bits/$network)
* Improved various code comments/docs
2010-11-07 20:31:48 +00:00
Alexandre Emsenhuber
85e0c158ee * Standardised file description headers
* added @file where needed
* added file description headers where needed
2010-10-23 14:16:26 +00:00
Antoine Musso
9e3b90a94d update my personal email address altern.org -> free.fr 2010-09-26 15:52:51 +00:00
Jack Phoenix
92ef4ae4e8 coding style tweaks 2010-08-08 16:57:31 +00:00
Alexandre Emsenhuber
5be509b0c1 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-08 14:23:14 +00:00
Alexandre Emsenhuber
ef9787a85f * Fixed some doxygen warnings
* Removed some useless spaces in the begining of lines
2010-03-09 21:51:05 +00:00
OverlordQ
a989843cd0 Code cleanup, covert leading spaces into tabs per coding style 2009-11-14 21:27:13 +00:00
Aaron Schulz
2e89016676 Take the IPv4 part of mapped addresses rather than broken '.'->':' replace 2009-08-08 01:22:15 +00:00
Aaron Schulz
418e7767b4 IPv6 padding cleanup - removed trailing ':' 2009-07-27 07:03:36 +00:00
Aaron Schulz
c0a1b76624 * IPv6 validation check fix for bug 19003
* Made regexps a bit more readable by breaking lines
2009-07-27 06:08:41 +00:00
Roan Kattouw
d99df49ed7 Fixes for r51236 per CR comments 2009-05-31 15:02:43 +00:00
Roan Kattouw
e7f76a6e77 Fix weird bug that caused IP::isInRange("80.0.0.0", "94.0.0.0/24") to return true because "52000000" >= "5E000000" (52000000 >= 5). Thanks, PHP. 2009-05-31 14:52:16 +00:00