You are here: Foswiki>Tasks Web>Item14014 (31 Jan 2018, GeorgeClark)Edit Attach

Item14014: Comment plugin unable to use template files in hierarchical webs in Foswiki 2.1.

Priority: Urgent
Current State: Closed
Released In: 2.1.1
Target Release: patch
Applies To: Engine
Component: FoswikiTemplates
Branches: master Release02x01 Item14033 Item13897 Item14380 Item14537
Reported By: PaulMerchantJr
Waiting For:
Last Change By: GeorgeClark
In Foswiki 2.1, the filter applied to template names in the function _readTemplateFile (in has changed. The value of the is copied from the AttachmentNameFilter preference and its default value omits "/" which was allowed in _readTemplateFile by the previous filter value.

Foswiki 2.0.3: $name =~ s/[^A-Za-z0-9_,.\/]//g;

Foswiki 2.1: $name =~ s/$Foswiki::regex{filenameInvalidCharRegex}//g; where $regex{filenameInvalidCharRegex} = qr/$Foswiki::cfg{AttachmentNameFilter}/; and $Foswiki::cfg{AttachmentNameFilter} = "[\\*?~^$@%`"'&|<>/\[\]#\x00-\x1f]"

In a Foswiki installation containing a hierarchical web structure such that web Y is a subweb of X, and web Y contains topics P and T where topic P contains a %COMMENT{template="T"}% macro, the Comment plugin calls Func::readTemplate("X/Y.T"). This request fails because the "/" is ultimately filtered out of the topic name when it reaches Template::_readTemplateFile.

Because CommentPlugin normalizes the web name, it is not possible to work around this issue using an explicit path in dot notation ("X.Y.T"). I don't see any other obvious work-arounds beyond moving the template topic out of the subweb.

-- PaulMerchantJr - 08 Mar 2016

Thanks for the detailed debugging. I think the fix is to use the NameFilter instead of AttachmentNameFilter when validating a template name. This should allow the slash.

NameFilter " #$%&'*:;<>?@[\]^`|~
AttachmentFilter "#$%&'*/<>?@[\]^`|~

-- GeorgeClark - 09 Mar 2016
Topic revision: r12 - 31 Jan 2018, GeorgeClark - This page was cached on 15 Jan 2020 - 00:18.

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