summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-12-17 19:23:14 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2020-12-17 19:23:14 +0000
commitc445c62b4d6488ddeefb27e587d3684f7b94e49b (patch)
tree23371107b6cba130ec60315d2a83abcc5eeb1f73
parentFix leak error with sanitizer in play (diff)
downloadicespider-c445c62b4d6488ddeefb27e587d3684f7b94e49b.tar.bz2
icespider-c445c62b4d6488ddeefb27e587d3684f7b94e49b.tar.xz
icespider-c445c62b4d6488ddeefb27e587d3684f7b94e49b.zip
Bail early if accept header is empty or all WS
-rw-r--r--icespider/core/ihttpRequest.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp
index 75b050a..025509f 100644
--- a/icespider/core/ihttpRequest.cpp
+++ b/icespider/core/ihttpRequest.cpp
@@ -37,6 +37,10 @@ namespace IceSpider {
Accepted
IHttpRequest::parseAccept(const std::string_view & acceptHdr)
{
+ if (acceptHdr.empty()
+ || std::find_if_not(acceptHdr.begin(), acceptHdr.end(), std::iswspace) == acceptHdr.end()) {
+ throw Http400_BadRequest();
+ }
auto accept = std::unique_ptr<FILE, decltype(&fclose)>(
fmemopen(const_cast<char *>(acceptHdr.data()), acceptHdr.length(), "r"), &fclose);
Accepted accepts;