From c6b8362eea8d40f7e52aaeda61246aa420078f61 Mon Sep 17 00:00:00 2001 From: helge Date: Fri, 8 Oct 2004 12:26:57 +0000 Subject: [PATCH] fixed WebDAV URL handling on MacOSX git-svn-id: http://svn.opengroupware.org/SOPE/trunk@231 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 14 +++++++ .../NGObjWeb/NGObjWeb/WEClientCapabilities.h | 2 +- sope-appserver/NGObjWeb/Version | 2 +- .../NGObjWeb/WEClientCapabilities.m | 14 +++++++ .../NGObjWeb/WebDAV/SoObjectDataSource.m | 31 ++++++++++++--- .../NGObjWeb/WebDAV/SoObjectResultEntry.h | 5 +-- .../NGObjWeb/WebDAV/SoObjectResultEntry.m | 39 +++++++++++++------ .../NGObjWeb/WebDAV/SoWebDAVRenderer.m | 25 +++++++++--- 8 files changed, 106 insertions(+), 26 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index e4e2cd6f..546a8062 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,17 @@ +2004-10-08 Helge Hess + + * v4.3.55 + + * WebDAV/SoObjectResultEntry.m, WebDAV/SoWebDAVRenderer.m: improved + debugging and error detection facilities + + * WebDAV/SoObjectDataSource.m: fixed URL construction on Cocoa + Foundation (you cannot use NSPathUtilities to work on URLs with that + Foundation) + + * WEClientCapabilities.m: added Goliath as a known (WebDAV) user agent, + added -isRSSClient method + 2004-10-07 Helge Hess * v4.3.54 diff --git a/sope-appserver/NGObjWeb/NGObjWeb/WEClientCapabilities.h b/sope-appserver/NGObjWeb/NGObjWeb/WEClientCapabilities.h index a5905d4f..38c83197 100644 --- a/sope-appserver/NGObjWeb/NGObjWeb/WEClientCapabilities.h +++ b/sope-appserver/NGObjWeb/NGObjWeb/WEClientCapabilities.h @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __WEExtensions_WEClientCapabilities_H__ #define __WEExtensions_WEClientCapabilities_H__ @@ -67,6 +66,7 @@ - (BOOL)isDAVClient; - (BOOL)isXmlRpcClient; - (BOOL)isBLogClient; +- (BOOL)isRSSClient; - (BOOL)doesSupportCSSOverflow; - (BOOL)doesSupportDHTMLDragAndDrop; diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index f96f5d30..178036b2 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=54 +SUBMINOR_VERSION:=55 # v4.3.42 requires libNGExtensions v4.3.116 # v4.3.40 requires libNGExtensions v4.3.115 diff --git a/sope-appserver/NGObjWeb/WEClientCapabilities.m b/sope-appserver/NGObjWeb/WEClientCapabilities.m index f61e8285..6c5b45cc 100644 --- a/sope-appserver/NGObjWeb/WEClientCapabilities.m +++ b/sope-appserver/NGObjWeb/WEClientCapabilities.m @@ -67,6 +67,7 @@ #define WEUA_SOPE 37 #define WEUA_Ecto 38 #define WEUA_NewsFire 39 +#define WEUA_Goliath 40 #define WEOS_UNKNOWN 0 #define WEOS_WINDOWS 1 @@ -333,6 +334,9 @@ else if (strstr(ua, "NewsFire")) { self->browser = WEUA_NewsFire; } + else if (strstr(ua, "Goliath")) { + self->browser = WEUA_Goliath; + } else if (strstr(ua, "SOPE/")) { self->browser = WEUA_SOPE; } @@ -426,6 +430,7 @@ case WEUA_KungLog: return @"KungLog"; case WEUA_Ecto: return @"Ecto"; case WEUA_NewsFire: return @"NewsFire"; + case WEUA_Goliath: return @"Goliath"; default: return @"unknown"; } } @@ -580,6 +585,7 @@ if (self->browser == WEUA_ZideLook) return YES; if (self->browser == WEUA_Entourage) return YES; if (self->browser == WEUA_Morgul) return YES; + if (self->browser == WEUA_Goliath) return YES; return NO; } @@ -594,6 +600,11 @@ if (self->browser == WEUA_Ecto) return YES; return NO; } +- (BOOL)isRSSClient { + if (self->browser == WEUA_NetNewsWire) return YES; + if (self->browser == WEUA_NewsFire) return YES; + return NO; +} - (BOOL)doesSupportCSSOverflow { if (![self isCSS1Browser]) @@ -1024,4 +1035,7 @@ static NSString *WEClientDetectorFormName = @"WEClientDetect"; NewsFire 'NewsFire/0.23' + + Goliath + 'Goliath/1.0.1 (Macintosh-Carbon; PPC)' */ diff --git a/sope-appserver/NGObjWeb/WebDAV/SoObjectDataSource.m b/sope-appserver/NGObjWeb/WebDAV/SoObjectDataSource.m index 6469f89c..ba757313 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoObjectDataSource.m +++ b/sope-appserver/NGObjWeb/WebDAV/SoObjectDataSource.m @@ -33,8 +33,10 @@ static BOOL debugOn = NO; + (void)initialize { - debugOn = [[NSUserDefaults standardUserDefaults] - boolForKey:@"SoObjectDataSourceDebugEnabled"]; + NSUserDefaults *ud; + + ud = [NSUserDefaults standardUserDefaults]; + debugOn = [ud boolForKey:@"SoObjectDataSourceDebugEnabled"]; } - (id)initWithObject:(id)_object inContext:(id)_ctx { @@ -95,6 +97,7 @@ static BOOL debugOn = NO; NSArray *queriedAttrNames; NSArray *orderings; NSString *childKey; + NSString *tmp; BOOL isBrief = YES; // do not encode "sub-errors", just omit the item [self debugWithFormat:@"performing flat query: %@", _fs]; @@ -131,7 +134,8 @@ static BOOL debugOn = NO; if (isBrief) // when the brief header is set, forget errors e = nil; } - else if ((child = [self->object lookupName:childKey inContext:_ctx acquire:NO])==nil) { + else if ((child = [self->object lookupName:childKey inContext:_ctx + acquire:NO])==nil) { /* not found */ [self debugWithFormat:@" did not find key '%@'", childKey]; @@ -176,9 +180,26 @@ static BOOL debugOn = NO; } /* calc URI */ - + + /* + Note: we cannot use NSPathUtilities, those will reformat the string on + Cocoa Foundation! (eg http://a => http:/a, remove double slashes) + */ childHref = [childKey stringByEscapingURL]; - childHref = [[_fs entityName] stringByAppendingPathComponent:childHref]; + tmp = [_fs entityName]; + if (![tmp hasSuffix:@"/"]) + tmp = [tmp stringByAppendingString:@"/"]; + childHref = [tmp stringByAppendingString:childHref]; + + if (debugOn) { + // TODO: this happens if we access using Goliath + if ([childHref hasPrefix:@"http:/"] && + ![childHref hasPrefix:@"http://"]) { + [self logWithFormat:@"BROKEN CHILD URL: %@ (entity=%@,key=%@)", + childHref, [_fs entityName], childKey]; + abort(); + } + } /* add errors if required */ diff --git a/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.h b/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.h index 1ed98fc5..04b5f6bc 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.h +++ b/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.h @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + Copyright (C) 2002-2004 SKYRIX Software AG - This file is part of OGo + This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #ifndef __WebDAV_SoObjectResultEntry_H__ #define __WebDAV_SoObjectResultEntry_H__ diff --git a/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.m b/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.m index 05b5ff2a..de7850b6 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.m +++ b/sope-appserver/NGObjWeb/WebDAV/SoObjectResultEntry.m @@ -1,7 +1,7 @@ /* - Copyright (C) 2000-2003 SKYRIX Software AG + Copyright (C) 2000-2004 SKYRIX Software AG - This file is part of OGo + This file is part of OpenGroupware.org. OGo is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the @@ -18,19 +18,35 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "SoObjectResultEntry.h" #include "common.h" @implementation SoObjectResultEntry +static BOOL debugOn = NO; + - (id)initWithURI:(NSString *)_href object:(id)_o values:(NSDictionary *)_d { - self->href = [_href copy]; - self->values = [_d retain]; - self->object = [_o retain]; + if ((self = [super init])) { + if (debugOn) { + // TODO: this happens if we access using Goliath + if ([_href hasPrefix:@"http:/"] && ![_href hasPrefix:@"http://"]) { + [self logWithFormat:@"BROKEN URL: %@", _href]; + [self release]; + abort(); + return nil; + } + } + + self->href = [_href copy]; + self->values = [_d retain]; + self->object = [_o retain]; + } return self; } +- (id)init { + return [self initWithURI:nil object:nil values:nil]; +} - (void)dealloc { [self->href release]; @@ -72,16 +88,17 @@ - (id)valueForKey:(NSString *)_key { if ([_key isEqualToString:@"{DAV:}href"]) return self->href; - else if ([_key isEqualToString:@"{DAV:}status"]) + + if ([_key isEqualToString:@"{DAV:}status"]) return nil; - else { -#if 1 + + if (!debugOn) return [self->values objectForKey:_key]; -#else + + { id v = [self->values objectForKey:_key]; [self logWithFormat:@"key %@: %@", _key, v]; return v; -#endif } } diff --git a/sope-appserver/NGObjWeb/WebDAV/SoWebDAVRenderer.m b/sope-appserver/NGObjWeb/WebDAV/SoWebDAVRenderer.m index 5fc01c2d..d6f36e8d 100644 --- a/sope-appserver/NGObjWeb/WebDAV/SoWebDAVRenderer.m +++ b/sope-appserver/NGObjWeb/WebDAV/SoWebDAVRenderer.m @@ -374,8 +374,19 @@ static BOOL formatOutput = NO; return baseURL; } -- (NSString *)tidyHref:(id)href baseURL:(id)baseURL { - href = [href stringValue]; +- (NSString *)tidyHref:(id)_href baseURL:(id)baseURL { + NSString *href; + + href = [_href stringValue]; + + if (debugOn) { + // TODO: this happens if we access using Goliath + if ([href hasPrefix:@"http:/"] && ![href hasPrefix:@"http://"]) { + [self logWithFormat:@"BROKEN URL: %@", _href]; + return nil; + } + } + if (href == nil) { if (debugOn) { [self logWithFormat: @@ -436,7 +447,7 @@ static BOOL formatOutput = NO; /* we do not map these DAV properties because they are very special */ if (!_namesOnly) { if ((href = [entry valueForKey:@"{DAV:}href"]) == nil) { - if ((key = [_propMap objectForKey:@"{DAV:}href"])) { + if ((key = [_propMap objectForKey:@"{DAV:}href"]) != nil) { if ((href = [entry valueForKey:key]) == nil) { if (debugOn) { [self debugWithFormat: @@ -475,7 +486,7 @@ static BOOL formatOutput = NO; [r appendContentString:@""]; if (formatOutput) [r appendContentCharacter:'\n']; - if (href) { + if ([href isNotNull]) { [r appendContentString:@""]; /* TODO: need to find out what is appropriate! While Cadaver and ZideLook @@ -493,7 +504,11 @@ static BOOL formatOutput = NO; [r appendContentString:@""]; if (formatOutput) [r appendContentCharacter:'\n']; } - + else { + [self logWithFormat: + @"WARNING: WebDAV result entry has no valid href: %@", entry]; + } + [r appendContentString:@""]; if (stat) { [r appendContentString:@""]; -- 2.39.5