From afdc9966f1bade4b99b7c938c6a684d75a12dff2 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Mon, 6 Aug 2018 23:12:29 +0000 Subject: 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 --- url.h | 27 +++++++++++++++++++++++---- 1 file 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: -- cgit v1.2.3