Skip to content

user without password does not parse #13

@garlick

Description

@garlick

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:p@example.com works, but http://u@example.com 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? */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions