Item14685: permissions read from the wrong topic
Priority: Urgent
Current State: Closed
Released In: 2.1.7
Target Release: patch
Applies To: Extension
Component: NatEditPlugin
Branches: Release02x01 master
When the
templatetopic
url parameter is set to the empty string will preferences be read from the
WebHome topic of the current web.
Below the problematic code in
edit.natedit.tmpl
.
Code:
%QUERY{"'%URLPARAM{"templatetopic" default="%WEB%.%TOPIC%"}%'/preferences[name='ALLOWTOPICCHANGE'].value" }%
Result:
It will then be executed as:
Code:
%QUERY{"''/preferences[name='ALLOWTOPICCHANGE'].value" }%
Result:
AdminUser
and
not as this:
Code:
%QUERY{"preferences[name='ALLOWTOPICCHANGE'].value" }%
Result:
Here is a patch to be tested:
diff --git a/NatEditPlugin/templates/edit.natedit.tmpl b/NatEditPlugin/templates/edit.natedit.tmpl
index aa28c3320..304be15c7 100644
--- a/NatEditPlugin/templates/edit.natedit.tmpl
+++ b/NatEditPlugin/templates/edit.natedit.tmpl
@@ -92,7 +92,10 @@
%TMPL:DEF{"selectedtab"}%%URLPARAM{"selectedtab"}%%TMPL:END%
%TMPL:DEF{"getpreference"}%%QUERY{
- "'%URLPARAM{"templatetopic" default="%WEB%.%TOPIC%"}%'/preferences[name='%name%'].value"
+ "%IF{"$'URLPARAM{templatetopic}'=''"
+ then="preferences[name='%name%'].value"
+ else="'%URLPARAM{"templatetopic"}%'/preferences[name='%name%'].value"
+ }%"
}%%TMPL:END%
--
MichaelDaum - 24 Apr 2018
I've tested locally. Seems to work fine, and still copies permissions when a template has them. Applied it to foswiki.org, and verified that the problem is fixed.
--
GeorgeClark - 25 Apr 2018