Fix hostname checking
parent
0d4b5ee989
commit
9d7d19c456
|
@ -117,24 +117,24 @@ void request_validate_header(server *srv, connection *con) {
|
|||
return;
|
||||
} else if (hh) {
|
||||
g_string_append_len(req->uri.host, GSTR_LEN((GString*) g_queue_peek_head(&hh->values)));
|
||||
if (parse_authority(&req->uri)) {
|
||||
if (parse_hostname(&req->uri)) {
|
||||
bad_request(srv, con, 400); /* bad request */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Need hostname in HTTP/1.1 */
|
||||
if (req->uri.host->len == 0 && req->http_version == HTTP_VERSION_1_1) {
|
||||
bad_request(srv, con, 400); /* bad request */
|
||||
return;
|
||||
}
|
||||
|
||||
/* may override hostname */
|
||||
if (!request_parse_url(srv, con)) {
|
||||
bad_request(srv, con, 400); /* bad request */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Need hostname in HTTP/1.1 */
|
||||
if (req->uri.host->len == 0 && req->http_version == HTTP_VERSION_1_1) {
|
||||
bad_request(srv, con, 400); /* bad request */
|
||||
return;
|
||||
}
|
||||
|
||||
/* content-length */
|
||||
hh = http_header_lookup_fast(req->headers, CONST_STR_LEN("content-length"));
|
||||
if (hh) {
|
||||
|
@ -228,8 +228,6 @@ void request_validate_header(server *srv, connection *con) {
|
|||
/* the may have a content-length */
|
||||
break;
|
||||
}
|
||||
|
||||
/* TODO: check hostname */
|
||||
}
|
||||
|
||||
void physical_init(physical *phys) {
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
#include "request.h"
|
||||
|
||||
LI_API gboolean parse_raw_url(request_uri *uri);
|
||||
LI_API gboolean parse_authority(request_uri *uri);
|
||||
LI_API gboolean parse_hostname(request_uri *uri);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
URI = scheme "://" (authority >mark %save_authority) URI_path;
|
||||
|
||||
parse_URI := URI | ("*" >mark %save_path) | URI_path;
|
||||
parse_Authority := authority;
|
||||
parse_Hostname := (host >mark_host %save_host) ( ":" port )?;
|
||||
|
||||
write data;
|
||||
}%%
|
||||
|
@ -89,7 +89,7 @@ gboolean parse_raw_url(request_uri *uri) {
|
|||
return (cs >= url_parser_first_final);
|
||||
}
|
||||
|
||||
gboolean parse_authority(request_uri *uri) {
|
||||
gboolean parse_hostname(request_uri *uri) {
|
||||
const char *p, *pe, *eof;
|
||||
const char *mark = NULL, *host_mark = NULL;
|
||||
int cs;
|
||||
|
@ -99,7 +99,7 @@ gboolean parse_authority(request_uri *uri) {
|
|||
eof = pe = uri->authority->str + uri->authority->len;
|
||||
|
||||
%% write init nocs;
|
||||
cs = url_parser_en_parse_Authority;
|
||||
cs = url_parser_en_parse_Hostname;
|
||||
|
||||
%% write exec;
|
||||
|
||||
|
|
Loading…
Reference in New Issue