Giter Club home page Giter Club logo

Comments (3)

jethrocarr avatar jethrocarr commented on June 22, 2024

Best fix is probably to move to using PHP's native IPv4 validation. We use it for IPv6, but don't use it for older IPv4 addresses.

396                 case "ipv4":
397                         $expression = "/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/";
398                 break;
399
400                 case "ipv4_cidr":
401                         $expression = "/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}[\/]*[1-9]*$/";
402                 break;
403
404                 case "ipv6":
405                         if (filter_var($_POST[$valuename], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
406                         {
407                                 return $_POST[$valuename];
408                         }
409                         else
410                         {
411                                 // there has been an error - flag the hourmins field as being incorrect input
412                                 $_SESSION["error"]["message"][] = "Provided address is not a valid IPv6 address";
413                                 $_SESSION["error"]["". $valuename . "-error"] = 1;
414                                 $_SESSION["error"][$valuename] = 0;
415
416                                 return "error";
417                         }
418                 break;
419
420                 case "ipv6_cidr":
421                         list($network, $cidr) = split("/", $_POST[$valuename]);
422
423                         if (filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
424                         {
425                                 return "$network/$cidr";
426                         }
427                         else
428                         {
429                                 // there has been an error - flag the hourmins field as being incorrect input
430                                 $_SESSION["error"]["message"][] = "Provided address is not a valid IPv6 address";
431                                 $_SESSION["error"]["". $valuename . "-error"] = 1;
432                                 $_SESSION["error"][$valuename] = 0;
433
434                                 return "error";
435                         }
436                 break;

PR welcome.

from namedmanager.

unixchina avatar unixchina commented on June 22, 2024

Best fix is probably to move to using PHP's native IPv4 validation. We use it for IPv6, but don't use it for older IPv4 addresses.

396                 case "ipv4":
397                         $expression = "/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}$/";
398                 break;
399
400                 case "ipv4_cidr":
401                         $expression = "/^(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)(?:[.](?:25[0-5]|2[0-4]\d|1\d\d|[1-9]\d|\d)){3}[\/]*[1-9]*$/";
402                 break;
403
404                 case "ipv6":
405                         if (filter_var($_POST[$valuename], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
406                         {
407                                 return $_POST[$valuename];
408                         }
409                         else
410                         {
411                                 // there has been an error - flag the hourmins field as being incorrect input
412                                 $_SESSION["error"]["message"][] = "Provided address is not a valid IPv6 address";
413                                 $_SESSION["error"]["". $valuename . "-error"] = 1;
414                                 $_SESSION["error"][$valuename] = 0;
415
416                                 return "error";
417                         }
418                 break;
419
420                 case "ipv6_cidr":
421                         list($network, $cidr) = split("/", $_POST[$valuename]);
422
423                         if (filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
424                         {
425                                 return "$network/$cidr";
426                         }
427                         else
428                         {
429                                 // there has been an error - flag the hourmins field as being incorrect input
430                                 $_SESSION["error"]["message"][] = "Provided address is not a valid IPv6 address";
431                                 $_SESSION["error"]["". $valuename . "-error"] = 1;
432                                 $_SESSION["error"][$valuename] = 0;
433
434                                 return "error";
435                         }
436                 break;

PR welcome.

v1.9.0 not working for /10,/20,/30...

from namedmanager.

unixchina avatar unixchina commented on June 22, 2024

Hi,

The ipv4_cidr regex for /10 subnet seems invalids. Here a regex that seems to be working :
http://www.regexpal.com/93987

It's working for me

from namedmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.