mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-03 12:11:33 +01:00
http: Enhance parser to detect .onion addresses.
* dirmngr/http.h (parsed_uri_s): Add flag 'onion'. * dirmngr/http.c (do_parse_uri): Set that flag. * dirmngr/t-http.c (main): Print flags. Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
10cca02c4c
commit
17ac843871
@ -1086,6 +1086,7 @@ do_parse_uri (parsed_uri_t uri, int only_local_part,
|
||||
uri->is_http = 0;
|
||||
uri->opaque = 0;
|
||||
uri->v6lit = 0;
|
||||
uri->onion = 0;
|
||||
|
||||
/* A quick validity check. */
|
||||
if (strspn (p, VALID_URI_CHARS) != n)
|
||||
@ -1172,15 +1173,16 @@ do_parse_uri (parsed_uri_t uri, int only_local_part,
|
||||
{
|
||||
uri->opaque = 1;
|
||||
uri->path = p;
|
||||
if (is_onion_address (uri->path))
|
||||
uri->onion = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
} /* End global URI part. */
|
||||
|
||||
/* Parse the pathname part */
|
||||
if (!p || !*p)
|
||||
return 0; /* We don't have a path. Okay. */
|
||||
|
||||
/* Parse the pathname part if any. */
|
||||
if (p && *p)
|
||||
{
|
||||
/* TODO: Here we have to check params. */
|
||||
|
||||
/* Do we have a query part? */
|
||||
@ -1194,10 +1196,9 @@ do_parse_uri (parsed_uri_t uri, int only_local_part,
|
||||
return GPG_ERR_BAD_URI; /* Path includes a Nul. */
|
||||
p = p2 ? p2 : NULL;
|
||||
|
||||
if (!p || !*p)
|
||||
return 0; /* We don't have a query string. Okay. */
|
||||
|
||||
/* Now parse the query string. */
|
||||
/* Parse a query string if any. */
|
||||
if (p && *p)
|
||||
{
|
||||
tail = &uri->query;
|
||||
for (;;)
|
||||
{
|
||||
@ -1214,6 +1215,11 @@ do_parse_uri (parsed_uri_t uri, int only_local_part,
|
||||
break; /* Ready. */
|
||||
p = p2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_onion_address (uri->host))
|
||||
uri->onion = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ struct parsed_uri_s
|
||||
unsigned int use_tls:1; /* Whether TLS should be used. */
|
||||
unsigned int opaque:1;/* Unknown scheme; PATH has the rest. */
|
||||
unsigned int v6lit:1; /* Host was given as a literal v6 address. */
|
||||
unsigned int onion:1; /* .onion address given. */
|
||||
char *auth; /* username/password for basic auth. */
|
||||
char *host; /* Host (converted to lowercase). */
|
||||
unsigned short port; /* Port (always set if the host is set). */
|
||||
|
@ -323,6 +323,11 @@ main (int argc, char **argv)
|
||||
}
|
||||
putchar ('\n');
|
||||
}
|
||||
printf ("Flags :%s%s%s%s\n",
|
||||
uri->is_http? " http":"",
|
||||
uri->opaque? " opaque":"",
|
||||
uri->v6lit? " v6lit":"",
|
||||
uri->onion? " onion":"");
|
||||
printf ("TLS : %s\n",
|
||||
uri->use_tls? "yes":
|
||||
(my_http_flags&HTTP_FLAG_FORCE_TLS)? "forced" : "no");
|
||||
|
Loading…
x
Reference in New Issue
Block a user