Changeset 715 for trunk/lib


Ignore:
Timestamp:
Feb 13, 2020 4:49:10 AM (4 years ago)
Author:
anonymous
Message:

Use a simpler test for IP in CIDR notation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r707 r715  
    279279    // Capture the full URL into the first match and only the first X characters into the second match.
    280280    // This will match URLs not preceded by " ' or = (URLs inside an attribute) or ` (Markdown quoted) or double-scheme (http://http://www.asdf.com)
    281     // Valid URL characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]@!$&'()*+,;=
     281    // https://stackoverflow.com/questions/1547899/which-characters-make-a-url-invalid/1547940#1547940
    282282    $regex = '@
    283283        \b                                 # Start with a word-boundary.
     
    13701370    $addr_binary = sprintf('%032b', ip2long($addr));
    13711371    foreach ($networks as $network) {
    1372         if (preg_match('![\d\.]{7,15}/\d{1,2}!', $network)) {
     1372        if (mb_strpos($network, '/') !== false) {
    13731373            // IP is in CIDR notation.
    13741374            list($cidr_ip, $cidr_bitmask) = explode('/', $network);
Note: See TracChangeset for help on using the changeset viewer.