From b48c574b08f925ea6134b6ff7481ccffc2e29358 Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Thu, 6 Jun 2013 20:35:34 +0900 Subject: [PATCH] "@" parsing within autority when it's valid hierarchical part character Change-Id: I0dd6456eb43984e0e8ec8847da8b90ddf50721de --- libiri/parse.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libiri/parse.c b/libiri/parse.c index ea12de7..2ed3e2f 100644 --- a/libiri/parse.c +++ b/libiri/parse.c @@ -428,7 +428,7 @@ iri_parse(const char *src) { iri_t *p; char *bufstart, *endp, *bufp, **sl; - const char *at, *colon, *slash, *t; + const char *at, *colon, *slash, *t, *slash3rd; size_t buflen, sc, cp; if(NULL == (p = (iri_t *) calloc(1, sizeof(iri_t)))) @@ -450,6 +450,24 @@ iri_parse(const char *src) /* We can disregard the colon if a slash appears before it */ colon = NULL; } + // "@" is valid character in hierarchical part of IRI + if(slash && colon && (colon[1] != '/' || colon[2] != '/')) + { + //if scheme not suffixed with ://, there is not autority + //therefore autority(and user within) is not set + at = NULL; + } + else if(at && slash && slash[1] && slash[2]) + { + slash3rd = strchr(slash + 2, '/'); + //here we know scheme suffix is "://" so autority can exist + //3rd slash should match start of hierarchical part if exists + //@ after that is valid character + if(slash3rd && slash3rd < at) + { + at = NULL; + } + } if(colon && !at) { /* Definitely a scheme */ -- 2.7.4