libyuarel icon indicating copy to clipboard operation
libyuarel copied to clipboard

user without password does not parse

Open garlick opened this issue 5 years ago • 1 comments

Hi, thanks for sharing your code! I'm dumping a one-off parser I wrote myself in another project for yours.

One issue I found is it seems the code that parses credentials requires both user and password. E.g. http://u:[email protected] works, but http://[email protected] does not.

Does this look like the right fix?

diff --git a/yuarel.c b/yuarel.c
index a5f313fb7..072bd76ad 100644
--- a/yuarel.c
+++ b/yuarel.c
@@ -180,12 +180,11 @@ yuarel_parse(struct yuarel *url, char *u)
                        *u = '\0';
 
                        u = strchr(url->username, ':');
-                       if (NULL == u) {
-                               return -1;
+                       if (NULL != u) {
+                               url->password = u + 1;
+                               *u = '\0';
                        }
 
-                       url->password = u + 1;
-                       *u = '\0';
                }
 
                /* Missing hostname? */

garlick avatar Oct 04 '19 17:10 garlick

Thank you, I will take a look at it :-)

jacketizer avatar Oct 09 '19 22:10 jacketizer