]> git.tdb.fi Git - libs/net.git/commitdiff
Reject requests with a relative path
authorMikko Rasa <tdb@tdb.fi>
Mon, 6 Apr 2015 22:24:18 +0000 (01:24 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 6 Apr 2015 22:24:18 +0000 (01:24 +0300)
As per the HTTP specification

source/http/server.cpp

index e0b34b382e8a9d86e0a9c0a862a2a9250fa2220a..ed3a2b9288339830ee89f0b56585960ddb24d398 100644 (file)
@@ -106,6 +106,11 @@ void Server::client_data_available(Client &cl)
                                        response = new Response(NOT_IMPLEMENTED);
                                        response->add_content("Method not implemented\n");
                                }
+                               else if(cl.request->get_path()[0]!='/')
+                               {
+                                       response = new Response(BAD_REQUEST);
+                                       response->add_content("Path must be absolute\n");
+                               }
                        }
                        catch(const exception &e)
                        {