From 2e152fdade11a2a6184e8f66a5557f516d86d46e Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 14 Dec 2008 19:03:58 +0000 Subject: [PATCH] Support username:password@ prefix to host when initialising from schem, host and path. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27290 72102866-910b-0410-8b05-ffd578937521 --- Source/NSURL.m | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/NSURL.m b/Source/NSURL.m index 152c67055..5fa639503 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -542,6 +542,17 @@ static unsigned urlAlign; = [aPath stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; if ([aHost length] > 0) { + NSRange r = [aHost rangeOfString: @"@"]; + NSString *auth = nil; + + /* Allow for authentication (username:password) before actual host. + */ + if (r.length > 0) + { + auth = [aHost substringToIndex: r.location]; + aHost = [aHost substringFromIndex: NSMaxRange(r)]; + } + /* Add square brackets around ipv6 address if necessary */ if ([[aHost componentsSeparatedByString: @":"] count] > 2 @@ -549,6 +560,12 @@ static unsigned urlAlign; { aHost = [NSString stringWithFormat: @"[%@]", aHost]; } + + if (auth != nil) + { + aHost = [NSString stringWithFormat: @"%@@%@", auth, aHost]; + } + if ([aPath length] > 0) { /*