repo: uritools
action: commit
revision: 
path_from: 
revision_from: afdc9966f1bade4b99b7c938c6a684d75a12dff2:
path_to: 
revision_to: 
git.thebackupbox.net
uritools
git clone git://git.thebackupbox.net/uritools
commit afdc9966f1bade4b99b7c938c6a684d75a12dff2
Author: epochqwert 
Date:   Mon Aug 6 23:12:29 2018 +0000

    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

diff --git a/url.h b/url.h
index a3ddc3e142747ec37b415fe7f0d0dd592f0cf411..
index ..f451b8d805e57cd54b0df93baba30ddbe47c2c6d 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:

-----END OF PAGE-----