From 9dc717441e7a58eea8a7a8f09e92e1e298939f01 Mon Sep 17 00:00:00 2001 From: helge Date: Sun, 3 Oct 2004 16:12:31 +0000 Subject: [PATCH] minor code cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@218 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 4 ++++ .../NGObjWeb/DynamicElements/WOHyperlink.m | 1 - .../DynamicElements/_WOComplexHyperlink.m | 20 +++++++++++++++---- sope-appserver/NGObjWeb/Version | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index cb96f497..9affb8af 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,7 @@ +2004-10-03 Helge Hess + + * DynamicElements/_WOComplexHyperlink.m: minor code cleanups (v4.3.51) + 2004-09-30 Helge Hess * WOHttpAdaptor/WOHttpAdaptor.m: print listen address as a string value diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOHyperlink.m b/sope-appserver/NGObjWeb/DynamicElements/WOHyperlink.m index eb616ed3..b8e70560 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOHyperlink.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOHyperlink.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WOHyperlink.h" #include "WOElement+private.h" diff --git a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m index 546f8637..37f2ab08 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m +++ b/sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m @@ -18,7 +18,6 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id$ #include "WOHyperlink.h" @@ -363,6 +362,15 @@ static BOOL debugStaticLinks = NO; /* URI generation */ +- (BOOL)shouldRewriteURLString:(NSString *)_s inContext:(WOContext *)_ctx { + // TODO: we need a binding to disable rewriting! + if ([_s hasPrefix:@"mailto:"]) + return NO; + if ([_s hasPrefix:@"javascript:"]) + return NO; + return YES; +} + - (BOOL)_appendHrefToResponse:(WOResponse *)_r inContext:(WOContext *)_ctx { NSString *s; id hrefValue; @@ -374,21 +382,24 @@ static BOOL debugStaticLinks = NO; if (hrefValue == nil) return NO; - + if ([hrefValue isKindOfClass:NSURLClass]) { s = [hrefValue stringValueRelativeToURL:base]; } else { s = [hrefValue stringValue]; - if (!([s hasPrefix:@"mailto:"] || [s hasPrefix:@"javascript:"])) { + if ([self shouldRewriteURLString:s inContext:_ctx]) { if ([s isAbsoluteURL]) { // TODO: why are we doing this? we could just pass through the string? // => probably to generate relative links url = [NSURLClass URLWithString:s]; } else if (base != nil) { - url = [NSURLClass URLWithString:s relativeToURL:base]; + /* avoid creating a new URL for ".", just return the base */ + url = [s isEqualToString:@"."] + ? base + : [NSURLClass URLWithString:s relativeToURL:base]; } else { [self logWithFormat:@"WARNING: missing base URL in context ..."]; @@ -402,6 +413,7 @@ static BOOL debugStaticLinks = NO; s, base]; return NO; } + s = [url stringValueRelativeToURL:base]; } } diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 5ac309c0..52af9667 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=50 +SUBMINOR_VERSION:=51 # v4.3.42 requires libNGExtensions v4.3.116 # v4.3.40 requires libNGExtensions v4.3.115 -- 2.39.5