1--TEST--
2Bug #71745 FILTER_FLAG_NO_RES_RANGE does not cover whole 127.0.0.0/8 range
3--FILE--
4<?php
5//https://tools.ietf.org/html/rfc6890#section-2.1
6
7$privateRanges = array();
8// 10.0.0.0/8
9$privateRanges['10.0.0.0/8'] = array('10.0.0.0', '10.255.255.255');
10
11// 169.254.0.0/16
12$privateRanges['168.254.0.0/16'] = array('169.254.0.0', '169.254.255.255');
13
14// 172.16.0.0/12
15$privateRanges['172.16.0.0/12'] = array('172.16.0.0', '172.31.0.0');
16
17// 192.168.0.0/16
18$privateRanges['192.168.0.0/16'] = array('192.168.0.0', '192.168.255.255');
19
20foreach ($privateRanges as $key => $range) {
21	list($min, $max) = $range;
22	var_dump($key);
23	var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE));
24	var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE));
25}
26
27$reservedRanges = array();
28
29// 0.0.0.0/8
30$reserverRanges['0.0.0.0/8'] = array('0.0.0.0', '0.255.255.255');
31
32// 10.0.0.0/8
33$reserverdRanges['10.0.0.0/8'] = array('10.0.0.0', '10.255.255.255');
34
35// 100.64.0.0/10
36$reserverdRanges['10.64.0.0/10'] = array('100.64.0.0', '100.127.255.255');
37
38// 127.0.0.0/8
39$reserverdRanges['127.0.0.0/8'] = array('127.0.0.0', '127.255.255.255');
40
41// 169.254.0.0/16
42$reserverdRanges['169.254.0.0/16'] = array('169.254.0.0', '169.254.255.255');
43
44// 172.16.0.0/12
45$reserverdRanges['172.16.0.0/12'] = array('172.16.0.0', '172.31.0.0');
46
47// 192.0.0.0/24
48$reserverdRanges['192.0.0.0/24'] = array('192.0.0.0', '192.0.0.255');
49
50// 192.0.0.0/29
51$reserverdRanges['192.0.0.0/29'] = array('192.0.0.0', '192.0.0.7');
52
53// 192.0.2.0/24
54$reserverdRanges['192.0.2.0/24'] = array('192.0.2.0', '192.0.2.255');
55
56// 198.18.0.0/15
57$reserverdRanges['198.18.0.0/15'] = array('198.18.0.0', '198.19.255.255');
58
59// 198.51.100.0/24
60$reserverdRanges['198.51.100.0/24'] = array('198.51.100.0', '198.51.100.255');
61
62// 192.88.99.0/24
63$reserverdRanges['192.88.99.0/24'] = array('192.88.99.0', '192.88.99.255');
64
65// 192.168.0.0/16
66$reserverdRanges['192.168.0.0/16'] = array('192.168.0.0', '192.168.255.255');
67
68// 203.0.113.0/24
69$reserverdRanges['203.0.113.0/24'] = array('203.0.113.0', '203.0.113.255');
70
71// 240.0.0.0/4 + 255.255.255.255/32
72$reserverdRanges['240.0.0.0/4'] = array('224.0.0.0', '255.255.255.255');
73
74foreach ($reserverdRanges as $key => $range) {
75	list($min, $max) = $range;
76	var_dump($key);
77	var_dump(filter_var($min, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE));
78	var_dump(filter_var($max, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE));
79}
80
81
82
83--EXPECT--
84string(10) "10.0.0.0/8"
85bool(false)
86bool(false)
87string(14) "168.254.0.0/16"
88string(11) "169.254.0.0"
89string(15) "169.254.255.255"
90string(13) "172.16.0.0/12"
91bool(false)
92bool(false)
93string(14) "192.168.0.0/16"
94bool(false)
95bool(false)
96string(10) "10.0.0.0/8"
97string(8) "10.0.0.0"
98string(14) "10.255.255.255"
99string(12) "10.64.0.0/10"
100string(10) "100.64.0.0"
101string(15) "100.127.255.255"
102string(11) "127.0.0.0/8"
103bool(false)
104bool(false)
105string(14) "169.254.0.0/16"
106bool(false)
107bool(false)
108string(13) "172.16.0.0/12"
109string(10) "172.16.0.0"
110string(10) "172.31.0.0"
111string(12) "192.0.0.0/24"
112string(9) "192.0.0.0"
113string(11) "192.0.0.255"
114string(12) "192.0.0.0/29"
115string(9) "192.0.0.0"
116string(9) "192.0.0.7"
117string(12) "192.0.2.0/24"
118string(9) "192.0.2.0"
119string(11) "192.0.2.255"
120string(13) "198.18.0.0/15"
121string(10) "198.18.0.0"
122string(14) "198.19.255.255"
123string(15) "198.51.100.0/24"
124string(12) "198.51.100.0"
125string(14) "198.51.100.255"
126string(14) "192.88.99.0/24"
127string(11) "192.88.99.0"
128string(13) "192.88.99.255"
129string(14) "192.168.0.0/16"
130string(11) "192.168.0.0"
131string(15) "192.168.255.255"
132string(14) "203.0.113.0/24"
133string(11) "203.0.113.0"
134string(13) "203.0.113.255"
135string(11) "240.0.0.0/4"
136string(9) "224.0.0.0"
137bool(false)
138