php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #80116 filter_var rejects scoped IPv6 literal addresses
Submitted: 2020-09-17 10:43 UTC Modified: 2021-08-05 17:31 UTC
From: kieran at supportpal dot com Assigned:
Status: Open Package: Filter related
PHP Version: 8.0.0beta3 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kieran at supportpal dot com
New email:
PHP Version: OS:

 

 [2020-09-17 10:43 UTC] kieran at supportpal dot com
Description:
------------
filter_var rejects IPv6 scoped literal addresses. Scoped literal addresses are described at https://en.wikipedia.org/wiki/IPv6_address#Scoped_literal_IPv6_addresses_(with_zone_index)



[RFC 4007](https://tools.ietf.org/html/rfc4007):

a common notation to specify the scope zone, an implementation SHOULD
support the following format:
            <address>%<zone_id>
 where
      <address> is a literal IPv6 address,
      <zone_id> is a string identifying the zone of the address, and
      `%' is a delimiter character to distinguish between <address> and
      <zone_id>.

Test script:
---------------
https://3v4l.org/Lqnm0

<?php

$ip = "fe80::3549:8417:2ad0:ef6a%4";
var_dump(filter_var($ip, FILTER_VALIDATE_IP));

Expected result:
----------------
return true

Actual result:
--------------
return false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-17 11:15 UTC] kieran at supportpal dot com
Perhaps a feature request for RFC 4007 support instead of a bug.

inet_pton also fails with the address mentioned in the example.
 [2021-08-05 17:31 UTC] cmb@php.net
-Type: Bug +Type: Feature/Change Request
 [2021-08-05 17:31 UTC] cmb@php.net
> Perhaps a feature request for RFC 4007 support instead of a bug.

Right.  And maybe this should only be enabled via a new flag.
 [2022-12-21 09:27 UTC] nazi dot farhadi3171 at gmail dot com
Works like a charm!
(https://www.arise-portal.com/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC