Prechádzať zdrojové kódy

path trim ?query#fragement

hewei.it 4 rokov pred
rodič
commit
fdee374633
1 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  1. 5 1
      http/server/HttpHandler.cpp

+ 5 - 1
http/server/HttpHandler.cpp

@@ -36,7 +36,11 @@ preprocessor:
             (req.method == HTTP_GET || req.method == HTTP_HEAD)) {
         // web service
         // path safe check
-        const char* req_path = req.path.c_str();
+        const char* s = req.path.c_str();
+        const char* e = s;
+        while (*e && *e != '?' && *e != '#') ++e;
+        std::string path = std::string(s, e);
+        const char* req_path = path.c_str();
         if (*req_path != '/' || strstr(req_path, "/../")) {
             res.status_code = HTTP_STATUS_BAD_REQUEST;
             goto make_http_status_page;