mirror of
https://github.com/LdesignMedia/moodle-availability_ipaddress.git
synced 2026-10-22 11:08:07 +02:00
Fix #2 - Reject IP addresses that Moodle cannot match
The custom IP field and the predefined ranges form accepted invalid entries such as 2001:db8::1garbage, 192.168.1.0/24garbage or 192.168.1.0/999. address_in_subnet() silently skips those entries, so a "must not" restriction with a typo let blocked users in. Validation now only accepts formats address_in_subnet() can match: a single address, a subnet (mask 0-32 / 0-128) or a range in the last group with end >= start. IPv6 forms cleanremoteaddr() cannot parse are rejected as well. JS and PHP share the same rules; PHP also checks each entry against address_in_subnet() as a safety net. - Allow spaces after commas in the restriction field - Support IPv6 ranges, e.g. 2001:db8::1-ff - Add PHPUnit tests for helper::is_valid_ipaddress_list() - Bump version to 2026101500 (5.3.2)
This commit is contained in:
1 parent
150067f43d
commit
06a5f9c8c9
10 files changed
+653
-198
No files matched your search
@@ -56,11 +56,12 @@ $string['ipaddresses_help'] = 'Enter IP addresses separated by commas. Supports
|
||||
$string['ipaddresses_help_help'] = '<p>Enter one or more IP addresses or ranges, separated by commas.</p>
|
||||
<p><strong>Examples:</strong></p>
|
||||
<ul>
|
||||
<li><strong>Single IP:</strong> <code>192.168.1.1</code></li>
|
||||
<li><strong>IP range:</strong> <code>192.168.1.1-255</code></li>
|
||||
<li><strong>Subnet:</strong> <code>192.168.1.0/24</code></li>
|
||||
<li><strong>Multiple:</strong> <code>192.168.1.1,10.0.0.0/8,172.16.0.1-255</code></li>
|
||||
</ul>';
|
||||
<li><strong>Single IP:</strong> <code>192.168.1.1</code> or <code>2001:db8::1</code></li>
|
||||
<li><strong>IP range:</strong> <code>192.168.1.1-255</code> or <code>2001:db8::1-ff</code></li>
|
||||
<li><strong>Subnet:</strong> <code>192.168.1.0/24</code> or <code>2001:db8::/32</code></li>
|
||||
<li><strong>Multiple:</strong> <code>192.168.1.1, 10.0.0.0/8, 172.16.0.1-255</code></li>
|
||||
</ul>
|
||||
<p>A range only changes the last part of the address. Use a subnet for an IPv6 network prefix, e.g. <code>2001:db8::/32</code> instead of <code>2001:db8::</code>.</p>';
|
||||
$string['enabled'] = 'Enabled';
|
||||
$string['sortorder'] = 'Sort order';
|
||||
$string['existing_ranges'] = 'Existing IP ranges';
|
||||
|
||||
Reference in new issue
Block a user