summaryrefslogtreecommitdiff
path: root/url.h
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2018-08-06 23:12:29 +0000
committerepochqwert <epoch@hacking.allowed.org>2018-08-06 23:12:29 +0000
commitafdc9966f1bade4b99b7c938c6a684d75a12dff2 (patch)
tree698d9209eae9475185884e99229b547dfc54e41a /url.h
parent8b7632d0ae0834cd1de94364a759ab2b76423595 (diff)
downloaduritools-afdc9966f1bade4b99b7c938c6a684d75a12dff2.tar.gz
uritools-afdc9966f1bade4b99b7c938c6a684d75a12dff2.zip
fixed a use of a variable where it might have not been defined and made a decimal check of port that should handle more URL types in a more sane way
Diffstat (limited to 'url.h')
-rw-r--r--url.h27
1 files changed, 23 insertions, 4 deletions
diff --git a/url.h b/url.h
index a3ddc3e..f451b8d 100644
--- a/url.h
+++ b/url.h
@@ -114,6 +114,23 @@ void urlfromline(struct url *u,char *line) {
}
}
}
+ if(u->port) {
+ for(i=0;u->port[i];i++) {
+ if(u->port[i] < '0' || u->port[i] > '9') {
+ //this port number isn't a number!
+ //it is probably a different portion of the url then... and the domain is probably the scheme.
+ if(u->domain && !u->scheme) {
+ u->scheme=u->domain;
+ u->domain=0;
+ }
+ if(!u->path) {
+ u->path=u->port;
+ u->port=0;
+ }
+ break;
+ }
+ }
+ }
if(u->domain) {//for magnet links.
if(strchr(u->domain,'?')) {
@@ -123,10 +140,12 @@ void urlfromline(struct url *u,char *line) {
}
}
- if(strchr(u->domain,':') && !strchr(u->domain,']')) {//for scheme:?query_string
- u->scheme=u->domain;
- *strchr(u->scheme,':')=0;
- u->domain=0;
+ if(u->domain) {
+ if(strchr(u->domain,':') && !strchr(u->domain,']')) {//for scheme:?query_string
+ u->scheme=u->domain;
+ *strchr(u->scheme,':')=0;
+ u->domain=0;
+ }
}
if(!u->scheme && u->username) {//for mailto: