From c404a898c215e3e9c28d4252e8fdbe0740db4b11 Mon Sep 17 00:00:00 2001 From: Tindy X <49061470+tindy2013@users.noreply.github.com> Date: Wed, 4 Dec 2019 21:59:10 +0800 Subject: [PATCH] Fix program crash when parsing a long URI list --- misc.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/misc.cpp b/misc.cpp index c06ecc3..7ed0422 100644 --- a/misc.cpp +++ b/misc.cpp @@ -401,7 +401,7 @@ std::string trim(const std::string& str) std::string getUrlArg(std::string url, std::string request) { - std::smatch result; + //std::smatch result; /* if (regex_search(url.cbegin(), url.cend(), result, std::regex(request + "=(.*?)&"))) { @@ -420,8 +420,16 @@ std::string getUrlArg(std::string url, std::string request) string_array vArray, arglist = split(url, "&"); for(std::string &x : arglist) { + /* if(regex_search(x.cbegin(), x.cend(), result, std::regex("^" + request + "=(.*)$"))) return result[1]; + */ + std::string::size_type epos = x.find("="); + if(epos != x.npos) + { + if(x.substr(0, epos) == request) + return x.substr(epos + 1); + } } return std::string(); }