Tag:Implementation of regular matching IP by ereg in PHP

  • Implementation of regular matching IP by ereg in PHP

    Time:2021-10-9

    Let’s start with a code snippet: Copy codeThe code is as follows: $ip = “1.1.1.255”.chr(0).”haha”;  if(ereg(“^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$”,$ip)) {          echo $ip;  } else {          echo “unknown”;  }  This ereg regular restricts the data of $IP to xxx.xxx.xxx.xxx. On the surface, the above code should output “unknown”, but actually it outputs “1.1.1.255haha”. Because the ereg function has a null truncation vulnerability, the regular filtering is […]