From c8484b694927f4fccb949040e027be09e2287733 Mon Sep 17 00:00:00 2001
From: garry-ut99 <72945564+garry-ut99@users.noreply.github.com>
Date: Sun, 3 Nov 2024 17:03:55 +0000
Subject: [PATCH] Updated "ipaddress"
---
Static-filter-syntax.md | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/Static-filter-syntax.md b/Static-filter-syntax.md
index d03ab2c..8b5c2cc 100644
--- a/Static-filter-syntax.md
+++ b/Static-filter-syntax.md
@@ -587,8 +587,8 @@ The value assigned to `ipaddress` can be ...
- ... a plain string which must match exactly a given IP address
e.g. `ipaddress=192.168.1.1` to match exactly IP address `192.168.1.1`
-- ... a plain string followed by a wildcard to match IP addresses starting with the pattern
- e.g. `ipaddress=192.168.*` to match IP addresses starting with `192.168.`
+- ... a plain string followed by a wildcard at the end to match IP addresses starting with the pattern
+ e.g. `ipaddress=192.168.*` to match IP addresses starting with `192.168.` (wildcards inside: `192.168.*.1` or at the beginning: `*.168.1.1` are not supported, but a regex can be used in such cases)
- ... a regex which will be matched against the IP address
e.g. `ipaddress=/^192.168.1.\d{1-2}/` to match IP address between `192.168.1.0` and `192.168.1.99`.
- ... `lan` to match [IP addresses reserved for private networks](https://en.wikipedia.org/wiki/Reserved_IP_addresses)
@@ -606,6 +606,21 @@ Examples:
Cached resources do not have a valid IP address and thus can't be a match to `ipaddress` option.
+The `ipaddress` value is not validated, so you can enter anything. Only one ipv4 or ipv6 address or regex is valid.
+
+Exclusions `~` and `|` operators are not supported, e.g. `ipaddress=~192.168.1.1` or `ipaddress=192.168.1.1|192.168.8.4`, however as partial solution a regex can be used, examples:
+
+```adb
+*$ipaddress=/^(?!95\.216\.7\.22|9\.9\.9\.9).*$/
+*$ipaddress=/^((?!95\.216\.7\.22|9\.9\.9\.9).)*$/
+```
+
+but the above solution is not perfect:
+- the first above filter doesn't match/exclude `95.216.7.22y` where `y` is any digit, for example `95.216.7.228`
+- the second above filter even worse: doesn't match/exclude: `x95.216.7.22y` where `x` and/or `y` is any digit, for example `195.216.7.22` or `95.216.7.221` or `195.216.7.221`.
+
+But still some users might find them useful.
+
Technical notes
First commit in [1.59.1b15](https://github.com/gorhill/uBlock/commit/c6dedd253f). Related commit: [1.59.1b17](https://github.com/gorhill/uBlock/commit/030d7334e4), [1.59.1b19](https://github.com/gorhill/uBlock/commit/6acf97bf51), [1.59.1rc1](https://github.com/gorhill/uBlock/commit/6a042f152b513bbf5b3c8623ea3fbe2574ac0e24), [1.59.1rc4*](https://github.com/uBlockOrigin/uBlock-issues/issues/3381).