summaryrefslogtreecommitdiff
path: root/url.h
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2018-04-30 06:58:27 +0000
committerepochqwert <epoch@hacking.allowed.org>2018-04-30 06:58:27 +0000
commit8b7632d0ae0834cd1de94364a759ab2b76423595 (patch)
tree5f0b6fada0d672eeb7c64457a264a97673333148 /url.h
parentaeab9cb12996631ee0ff36e4955d0db1b68fda0a (diff)
downloaduritools-8b7632d0ae0834cd1de94364a759ab2b76423595.tar.gz
uritools-8b7632d0ae0834cd1de94364a759ab2b76423595.zip
added a hack to only ignore the first // when separating at the domain/path separation. fixed a dumb bug where uninitiallized string was being used as the value of the port. probably me testing something that I forgot about.
Diffstat (limited to 'url.h')
-rw-r--r--url.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/url.h b/url.h
index df0ef90..a3ddc3e 100644
--- a/url.h
+++ b/url.h
@@ -32,11 +32,16 @@ struct url {
void urlfromline(struct url *u,char *line) {
int i;
+ char hack=0;//we need to allow for // as host//path separator
//split at first single / into line and path
+ //this fails to split scheme://host//path into: scheme, host, /path. needs to be first single / or second double-or-more-/
for(i=0;line[i];i++) {
if(line[i] == '/' && line[i+1] == '/') {
- i++;
- continue;
+ if(!hack) {//only skip out on the first // because it is probably used in the scheme.
+ hack=1;
+ i++;
+ continue;
+ }
}
if(line[i] == '/') {
line[i]=0;
@@ -143,7 +148,7 @@ void magic_and_defaults(struct url *u) {
serv=getservbyname(u->scheme,strcmp(u->scheme,"udp")?"tcp":"udp");//gets default port for the scheme. http -> 80
if(serv) snprintf(sport,sizeof(sport)-1,"%d",ntohs(serv->s_port));
// else snprintf(sport,sizeof(sport)-1,"%d",serv);
- u->port=AorB(u->port,AorB(getenv("URL_PORT"),(serv||1?strdup(sport):"DEFAULT")));
+ u->port=AorB(u->port,AorB(getenv("URL_PORT"),(serv?strdup(sport):"DEFAULT")));
// if(!strcmp(u->port,"DEFAULT")) {
//this shouldn't happen most of the time. :/