From 37a80c5e5a5ca355274f9ad1ab260f51bd159942 Mon Sep 17 00:00:00 2001 From: CaS Date: Sat, 24 Aug 2002 06:16:13 +0000 Subject: [PATCH] mproved MacOS-X compatibility. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14323 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 15 +++++++-------- Source/NSURL.m | 12 ++++++++++-- Testing/basic.m | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b0bec94d..bf042d500 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,14 +1,13 @@ 2002-08-24 Richard Frith-Macdonald * Source/NSURL.m: Hacks for compatibility with MacOS-X in returning - path of a file URL ... the RFC says we shouldn't, but MacOS-X does. - Also when creating relative file URLs the MacOS-X code doesn't - strip the last patch component of the base URL as it should ... - we emulate that too. - Final note ... the MacOS-X code inserts 'localhost' as a host name - for a file URL which it shouldnt (a file URL has no host part) but - we don't emulate that at present (perhaps never as I can't see it - being very useful). + path of a file URL ... the RFC says we should only return a path + for a generic URL (scheme://user:passwd@host:port/path#frag?query) + which a file URL certainly isn't. However, for compatibility we + now treat a file URL more like a generic one. + Also when creating absolute file URLs from base plus relative, + the MacOS-X code doesn't strip the last path component of the + base URL as it should ... we emulate that too. 2002-08-22 Richard Frith-Macdonald diff --git a/Source/NSURL.m b/Source/NSURL.m index 4c7792363..783dcdb12 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -894,7 +894,15 @@ static void unescape(const char *from, char * to) } } - if (base != 0 + if (buf->isFile == YES) + { + buf->user = 0; + buf->password = 0; + buf->host = "localhost"; + buf->port = 0; + buf->isGeneric = YES; + } + else if (base != 0 && buf->user == 0 && buf->password == 0 && buf->host == 0 && buf->port == 0) { @@ -1203,7 +1211,7 @@ static void unescape(const char *from, char * to) /* * If this scheme is from a URL without generic format, there is no path. */ - if (myData->isGeneric == YES || myData->isFile == YES) + if (myData->isGeneric == YES) { unsigned int len = (_baseURL ? strlen(baseData->path) : 0) + strlen(myData->path) + 3; diff --git a/Testing/basic.m b/Testing/basic.m index d9f444ff3..e8f648e71 100644 --- a/Testing/basic.m +++ b/Testing/basic.m @@ -9,7 +9,7 @@ static void test1(void) NSURL *baseURL = [NSURL fileURLWithPath:@"/usr/local/bin"]; NSURL *url = [NSURL URLWithString:@"filename" relativeToURL:baseURL]; NSString *result = [url absoluteString]; - NSString *expected = @"file:/usr/local/bin/filename"; + NSString *expected = @"file://localhost/usr/local/bin/filename"; if ([result isEqualToString:expected]) NSLog(@"test 1 ok");