From a97a2de9b95bd7e677c4831c6b6ddaef50bfa913 Mon Sep 17 00:00:00 2001 From: Waweic Date: Wed, 18 Nov 2020 15:27:10 +0100 Subject: Add username and ipv6 literals to authority regex --- src/gmutil.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gmutil.c') diff --git a/src/gmutil.c b/src/gmutil.c index 04621e54..691260dc 100644 --- a/src/gmutil.c +++ b/src/gmutil.c @@ -41,7 +41,9 @@ void init_Url(iUrl *d, const iString *text) { urlPattern_ = new_RegExp("^(([^:/?#]+):)?(//([^/?#]*))?" "([^?#]*)(\\?([^#]*))?(#(.*))?", caseInsensitive_RegExpOption); - authPattern_ = new_RegExp("([^:]+)(:([0-9]+))?", caseInsensitive_RegExpOption); + authPattern_ = new_RegExp("(([^@]+)@)?(([^:\\[\\]]+)" + "|(\\[[0-9a-f:]+\\]))(:([0-9]+))?", + caseInsensitive_RegExpOption); } iZap(*d); iRegExpMatch m; @@ -55,8 +57,8 @@ void init_Url(iUrl *d, const iString *text) { /* Check if the authority contains a port. */ init_RegExpMatch(&m); if (matchRange_RegExp(authPattern_, d->host, &m)) { - d->host = capturedRange_RegExpMatch(&m, 1); - d->port = capturedRange_RegExpMatch(&m, 3); + d->host = capturedRange_RegExpMatch(&m, 3); + d->port = capturedRange_RegExpMatch(&m, 7); } } } -- cgit v1.2.3