repo: uritools action: commit revision: path_from: revision_from: afdc9966f1bade4b99b7c938c6a684d75a12dff2: path_to: revision_to:
commit afdc9966f1bade4b99b7c938c6a684d75a12dff2 Author: epochqwertDate: 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
--- 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-----