]> git.tdb.fi Git - libs/net.git/commitdiff
Fix processing of IPv6 addresses in HTTP server
authorMikko Rasa <tdb@tdb.fi>
Sun, 11 Dec 2022 16:26:02 +0000 (18:26 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 11 Dec 2022 16:26:44 +0000 (18:26 +0200)
source/http/server.cpp

index 9c9a876a411bd28616922edef1f535f5df4cb525..04bae0b4d8c24f7f9e72177c923c19fc2234083c 100644 (file)
@@ -146,7 +146,7 @@ void Server::client_data_available(Client &cl)
                                cl.request = make_unique<Request>(Request::parse(cl.in_buf));
 
                                string addr_str = cl.sock->get_peer_address().str();
-                               string::size_type colon = addr_str.find(':');
+                               string::size_type colon = addr_str.find(':', (addr_str[0]=='[' ? addr_str.find(']')+1 : 0));
                                cl.request->set_header("-Client-Host", addr_str.substr(0, colon));
 
                                if(cl.request->get_method()!="GET" && cl.request->get_method()!="POST")