aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2025-04-09 15:54:54 +0200
committerKim Alvefur <zash@zash.se>2025-04-09 15:54:54 +0200
commit3873c984a3e475c8410f8856f0e2a35231356d70 (patch)
tree0cfc9dfe5f6bff4f7da6724ea56564fd01e5e1a2
parent86bb005c57bc8f437dea94ea5bc71ef524509445 (diff)
downloadprosody-3873c984a3e475c8410f8856f0e2a35231356d70.tar.gz
prosody-3873c984a3e475c8410f8856f0e2a35231356d70.zip
mod_http: Fix IP address normalization (Thanks Boris)
This fixes the problem that an un-bracketed IPv6 address will not match the first pattern (since it matches brackets) and instead the first decimal digits will match the pattern meant to strip port numbers from IPv4 addresses, e.g. 2001:db8::1 --> 2000 This pattern instead matches enough of a regular IPv4 address to make an IPv6 address fall back to the last case.
-rw-r--r--plugins/mod_http.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index c13a2363..9be2b286 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -331,7 +331,7 @@ local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1",
--- deal with [ipv6]:port / ip:port format
local function normal_ip(ip)
- return ip:match("^%[([%x:]*)%]") or ip:match("^([%d.]+)") or ip;
+ return ip:match("^%[([%x:]*)%]") or ip:match("^%d+%.%d+%.%d+%.%d+") or ip;
end
local function is_trusted_proxy(ip)