|
|
@@ -2213,6 +2213,22 @@ process_header_line (struct MHD_Connection *connection,
|
|
|
_("Received malformed line (no colon). Closing connection.\n"));
|
|
|
return MHD_NO;
|
|
|
}
|
|
|
+ if (0 != (MHD_USE_PEDANTIC_CHECKS & connection->daemon->options))
|
|
|
+ {
|
|
|
+ /* check for whitespace before colon, which is not allowed
|
|
|
+ by RFC 7230 section 3.2.4; we count space ' ' and
|
|
|
+ tab '\t', but not '\r\n' as those would have ended the line. */
|
|
|
+ const char *white;
|
|
|
+
|
|
|
+ white = strchr (line, ' ');
|
|
|
+ if ( (NULL != white) &&
|
|
|
+ (white < colon) )
|
|
|
+ return MHD_NO;
|
|
|
+ white = strchr (line, '\t');
|
|
|
+ if ( (NULL != white) &&
|
|
|
+ (white < colon) )
|
|
|
+ return MHD_NO;
|
|
|
+ }
|
|
|
/* zero-terminate header */
|
|
|
colon[0] = '\0';
|
|
|
colon++; /* advance to value */
|