Changeset

10950:a23328c46389 0.11

net.http.server: Strip port from Host header in IPv6 friendly way (fix #1302) E.g. given `[::1]:5280` it would previously result in only `[` instead of the correct `[::1]`
author Kim Alvefur <zash@zash.se>
date Tue, 23 Jun 2020 15:39:31 +0200
parents 10947:801b9d5957a6
children 10951:f4215f8baa5d
files net/http/server.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/net/http/server.lua	Mon Jun 22 14:56:44 2020 +0200
+++ b/net/http/server.lua	Tue Jun 23 15:39:31 2020 +0200
@@ -207,7 +207,7 @@
 	};
 	conn._http_open_response = response;
 
-	local host = (request.headers.host or ""):match("[^:]+");
+	local host = (request.headers.host or ""):gsub(":%d+$","");
 
 	-- Some sanity checking
 	local err_code, err;