Item13925: Leading spaces in DefaultUrlHost causes malformed URL links.

Priority: Low
Current State: Closed
Released In: 2.1.0
Target Release: minor
Applies To: Engine
Component: Configure
Branches: master Release02x00 Item13897
Reported By: AlexAnder
Waiting For:
Last Change By: GeorgeClark
I've setup a wiki to use NatSkin globally in Site preferences. The mail notification is working for users who subscribe to the topics. I'm using a cronjob to push the notification with the following code:

cd /var/www/wiki && /usr/bin/perl -I /var/www/wiki/bin tools/mailnotify -q -nonews

When the user receives the notification, link to the topic is malformed in the HTML message:

<h2>Production // Wiki </h2>
<p>New or changed topics in the Production web, since 12 Jan 2016 - 17:32 GMT:</p>
<ul style="margin:1em 0;padding:0 0 0 1.5em;"><li style="margin:0 0 1em"> <a class='natExternalLink' href="http://myserver/wiki/%3Ca%20href="http://myserver/wiki/Production/MicrosoftOfficeMacros"">http://myserver/wiki/Production/MicrosoftOfficeMacros"</a>>Microsoft Office Macros</a> 
<br />
<a href="http://myserver/wiki/Main/AlexAnder">AlexAnder</a>, 13 Jan 2016 - 09:10

I've workaround this issue by creating a copy of the original template: templates/mailnotify.nat.tmpl

Original code:
%TMPL:DEF{"HTML:middle"}%<li style="margin:0 0 1em"> <a href="%SCRIPTURL{view}%/%ENCODE{%WEB%}%/%ENCODE{%TOPIC%}%">%GETTOPICTITLE{"%WEB%.%TOPIC%"}%</a>

Temporary fix:
%TMPL:DEF{"HTML:middle"}%<li style="margin:0 0 1em"> %SCRIPTURL{view}%/%ENCODE{%WEB%}%/%ENCODE{%TOPIC%}%

After this change the URL link was sent as:

<ul style="margin:1em 0;padding:0 0 0 1.5em;"><li style="margin:0 0 1em">  <a class='natExternalLink' href="http://myserver/wiki/Production/MicrosoftOfficeMacros">http://myserver/wiki/Production/MicrosoftOfficeMacros</a>

-- AlexAnder - 15 Jan 2016

Please check your the settings $Foswiki::cfg{ScriptUrlPath} and $Foswiki::cfg{ScriptUrlPaths}{view} in your LocalSite.cfg. What are their values?

Try disabling $Foswiki::cfg{NatSkin}{DetectExternalLinks}.

-- MichaelDaum - 15 Jan 2016

As usual you put me on the right direction, the issue is now fixed, but not by disabling: $Foswiki::cfg{NatSkin}{DetectExternalLinks} it was something else.

The values seems to be OK for my setup:

$Foswiki::cfg{ScriptUrlPath} = '/wiki/bin'; $Foswiki::cfg{ScriptUrlPaths}{view} = '/wiki';

I'm always using the web interface to configure the settings. Within my LocalSite.cfg I've found an extra space in my DefaultUrlHost:

$Foswiki::cfg{DefaultUrlHost} = ' http://servername';

Strangely when I check the configure web page, there was no visible space one it. In the configure web page I deleted everything in the text box, manually typed the URL of my server and saved the settings. After doing this the settings was saved properly:

$Foswiki::cfg{DefaultUrlHost} = 'http://servername';

Now everything works properly, thank you so much!

-- AlexAnder - 18 Jan 2016

The configure checker should have been flagging DefaultUrlHost with a warning that "Current setting does not match HTTP_HOST servername". I'll add a check for leading spaces for 2.0.4 / 2.1.

-- GeorgeClark - 18 Jan 2016

ItemTemplate edit

Summary Leading spaces in DefaultUrlHost causes malformed URL links.
ReportedBy AlexAnder
Codebase 2.1.0 beta1, 2.0.3, 2.0.2, trunk
SVN Range
AppliesTo Engine
Component Configure
Priority Low
CurrentState Closed
Checkins distro:b8e2034fb42a distro:360cdc1824c7
TargetRelease minor
ReleasedIn 2.1.0
CheckinsOnBranches master Release02x00 Item13897
masterCheckins distro:b8e2034fb42a
ItemBranchCheckins distro:b8e2034fb42a
Release02x00Checkins distro:360cdc1824c7
Topic revision: r6 - 04 Mar 2016, GeorgeClark - This page was cached on 23 Sep 2017 - 17:17.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License