From 03d83ffad34cf5b509f83ca277c35a2b3b821b15 Mon Sep 17 00:00:00 2001 From: Manuel Guesdon Date: Tue, 1 Jul 2014 14:11:26 +0000 Subject: [PATCH] * GSWeb/GSWHyperlink.m fix -appendAttribute:... for nil href value git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@37974 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 3 ++ GSWeb/GSWHyperlink.m | 95 ++++++++++++++++++++++---------------------- 2 files changed, 50 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55bc1a6..af91e93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-07-01 Manuel Guesdon + * GSWeb/GSWHyperlink.m + fix -appendAttribute:... for nil href value 2014-06-11 Manuel Guesdon * GSWeb/GSWAssociation.m fix EOValidatedObjectUserInfoKey value diff --git a/GSWeb/GSWHyperlink.m b/GSWeb/GSWHyperlink.m index 7c1f559..eca8b64 100644 --- a/GSWeb/GSWHyperlink.m +++ b/GSWeb/GSWHyperlink.m @@ -366,70 +366,69 @@ static Class NSStringClass = Nil; GSWResponse_appendContentCharacter(response,'"'); } - else if (_href != nil) + else { + NSString* hrefValue = nil; GSWComponent * component = GSWContext_component(context); - NSString* hrefValue = [_href valueInComponent:component]; - - if (hrefValue==nil) - hrefValue=@""; - else - hrefValue=NSStringWithObject(hrefValue); - - GSWResponse_appendContentCharacter(response,' '); - GSWResponse_appendContentAsciiString(response,href__Key); - GSWResponse_appendContentCharacter(response,'='); - GSWResponse_appendContentCharacter(response,'"'); - - if ([hrefValue isRelativeURL] - && ![hrefValue isFragmentURL]) + if (_href != nil + && (hrefValue = [_href valueInComponent:component]) != nil) { - NSString * url = [context _urlForResourceNamed:hrefValue - inFramework:nil]; - if (url != nil) - GSWResponse_appendContentString(response,url); - else - { - GSWResponse_appendContentAsciiString(response,[component baseURL]); - GSWResponse_appendContentCharacter(response,'/'); - GSWResponse_appendContentString(response,hrefValue); - } - } - else - { - GSWResponse_appendContentString(response,hrefValue); - } + hrefValue = NSStringWithObject(hrefValue); - [self _appendQueryStringToResponse:response - inContext:context - requestHandlerPath:nil - htmlEscapeURL:YES]; - - [self _appendFragmentToResponse: response - inContext:context]; - - GSWResponse_appendContentCharacter(response,'"'); - } - else if (_fragmentIdentifier != nil) - { - GSWComponent * component = GSWContext_component(context); - id fragmentIdentifierValue = [_fragmentIdentifier valueInComponent:component]; - if (fragmentIdentifierValue != nil) - { GSWResponse_appendContentCharacter(response,' '); GSWResponse_appendContentAsciiString(response,href__Key); GSWResponse_appendContentCharacter(response,'='); GSWResponse_appendContentCharacter(response,'"'); + if ([hrefValue isRelativeURL] + && ![hrefValue isFragmentURL]) + { + NSString * url = [context _urlForResourceNamed:hrefValue + inFramework:nil]; + if (url != nil) + GSWResponse_appendContentString(response,url); + else + { + GSWResponse_appendContentAsciiString(response,[component baseURL]); + GSWResponse_appendContentCharacter(response,'/'); + GSWResponse_appendContentString(response,hrefValue); + } + } + else + { + GSWResponse_appendContentString(response,hrefValue); + } + [self _appendQueryStringToResponse:response inContext:context requestHandlerPath:nil htmlEscapeURL:YES]; - GSWResponse_appendContentCharacter(response,'#'); - GSWResponse_appendContentString(response,NSStringWithObject(fragmentIdentifierValue)); + [self _appendFragmentToResponse: response + inContext:context]; + GSWResponse_appendContentCharacter(response,'"'); } + else if (_fragmentIdentifier != nil) + { + id fragmentIdentifierValue = [_fragmentIdentifier valueInComponent:component]; + if (fragmentIdentifierValue != nil) + { + GSWResponse_appendContentCharacter(response,' '); + GSWResponse_appendContentAsciiString(response,href__Key); + GSWResponse_appendContentCharacter(response,'='); + GSWResponse_appendContentCharacter(response,'"'); + + [self _appendQueryStringToResponse:response + inContext:context + requestHandlerPath:nil + htmlEscapeURL:YES]; + + GSWResponse_appendContentCharacter(response,'#'); + GSWResponse_appendContentString(response,NSStringWithObject(fragmentIdentifierValue)); + GSWResponse_appendContentCharacter(response,'"'); + } + } } }