mirror of
https://git.gnunet.org/libmicrohttpd.git
synced 2026-09-25 04:09:31 +03:00
expand strictness to cover spaces in URL
This commit is contained in:
@@ -1470,14 +1470,18 @@ enum MHD_OPTION
|
||||
MHD_OPTION_LISTEN_BACKLOG_SIZE = 28,
|
||||
|
||||
/**
|
||||
* If set to 1 - be strict about the protocol (as opposed to as
|
||||
* tolerant as possible). Specifically, at the moment, this flag
|
||||
* causes MHD to reject HTTP 1.1 connections without a "Host" header.
|
||||
* This is required by the standard, but of course in violation of
|
||||
* the "be as liberal as possible in what you accept" norm. It is
|
||||
* recommended to set this to 1 if you are testing clients against
|
||||
* MHD, and 0 in production.
|
||||
* This option should be followed by an `int` argument.
|
||||
* If set to 1 - be strict about the protocol. Use -1 to be
|
||||
* as tolerant as possible.
|
||||
*
|
||||
* Specifically, at the moment, at 1 this flag
|
||||
* causes MHD to reject HTTP 1.1 connections without a "Host" header,
|
||||
* and to disallow spaces in the URL or (at -1) in HTTP header key strings.
|
||||
*
|
||||
* These are required by some versions of the standard, but of
|
||||
* course in violation of the "be as liberal as possible in what you
|
||||
* accept" norm. It is recommended to set this to 1 if you are
|
||||
* testing clients against MHD, and 0 in production. This option
|
||||
* should be followed by an `int` argument.
|
||||
*/
|
||||
MHD_OPTION_STRICT_FOR_CLIENT = 29
|
||||
};
|
||||
|
||||
@@ -1803,6 +1803,14 @@ parse_initial_message_line (struct MHD_Request *request,
|
||||
line_len - (uri - line));
|
||||
}
|
||||
}
|
||||
if ( (1 <= daemon->strict_for_client) &&
|
||||
(NULL != memchr (line,
|
||||
' ',
|
||||
http_version - line)) )
|
||||
{
|
||||
/* space exists in URI and we are supposed to be strict, reject */
|
||||
return MHD_NO;
|
||||
}
|
||||
if (NULL != daemon->early_uri_logger_cb)
|
||||
{
|
||||
request->client_context
|
||||
|
||||
@@ -2241,6 +2241,14 @@ parse_initial_message_line (struct MHD_Connection *connection,
|
||||
line_len - (uri - line));
|
||||
}
|
||||
}
|
||||
if ( (1 <= daemon->strict_for_client) &&
|
||||
(NULL != memchr (line,
|
||||
' ',
|
||||
http_version - line)) )
|
||||
{
|
||||
/* space exists in URI and we are supposed to be strict, reject */
|
||||
return MHD_NO;
|
||||
}
|
||||
if (NULL != daemon->uri_log_callback)
|
||||
{
|
||||
connection->client_aware = true;
|
||||
|
||||
Reference in New Issue
Block a user