diff options
author | epochqwert <epoch@hacking.allowed.org> | 2018-04-30 06:58:27 +0000 |
---|---|---|
committer | epochqwert <epoch@hacking.allowed.org> | 2018-04-30 06:58:27 +0000 |
commit | 8b7632d0ae0834cd1de94364a759ab2b76423595 (patch) | |
tree | 5f0b6fada0d672eeb7c64457a264a97673333148 | |
parent | aeab9cb12996631ee0ff36e4955d0db1b68fda0a (diff) | |
download | uritools-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.
-rw-r--r-- | url.h | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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. :/ |