Skip to content
Snippets Groups Projects
Commit ed62aab2 authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-11478: Documents with special characters in their name are not displayed in the tree

* Fix the problem in the tree widget untill it's fixed upstream.
* Escape the macro parameter values in DocumentTree macro and Navigation panel.
parent fd467faf
No related branches found
No related tags found
No related merge requests found
...@@ -188,6 +188,7 @@ ...@@ -188,6 +188,7 @@
</class> </class>
<property> <property>
<code>{{velocity}} <code>{{velocity}}
#macro (escapeMacroParam $value)$!value.replaceAll('([~"])', '~$1')#end
#set ($docTreeConfig = { #set ($docTreeConfig = {
'showWikis': false, 'showWikis': false,
'showWikiPrettyName': true, 'showWikiPrettyName': true,
...@@ -208,13 +209,14 @@ ...@@ -208,13 +209,14 @@
#set ($discard = $resourceParams.put($entry.key, $value)) #set ($discard = $resourceParams.put($entry.key, $value))
#end #end
#end #end
#set ($reference = "path:$xwiki.getURL($xcontext.macro.doc.documentReference, 'get', $escapetool.url($resourceParams))")
#set ($editable = $xcontext.macro.params.readOnly != 'true') #set ($editable = $xcontext.macro.params.readOnly != 'true')
#set ($isFullWidthAvailable = $xcontext.macro.params.compact != 'true') #set ($isFullWidthAvailable = $xcontext.macro.params.compact != 'true')
#set ($links = $xcontext.macro.params.links == 'true') #set ($links = $xcontext.macro.params.links == 'true')
#set ($checkboxes = $xcontext.macro.params.checkboxes == 'true') #set ($checkboxes = $xcontext.macro.params.checkboxes == 'true')
{{tree reference="path:$xwiki.getURL($xcontext.macro.doc.documentReference, 'get', $escapetool.url($resourceParams))" {{tree reference="#escapeMacroParam($reference)" root="#escapeMacroParam($xcontext.macro.params.root)"
root="$!xcontext.macro.params.root" dragAndDrop="$editable" contextMenu="$editable" icons="$isFullWidthAvailable" dragAndDrop="$editable" contextMenu="$editable" icons="$isFullWidthAvailable" edges="$isFullWidthAvailable"
edges="$isFullWidthAvailable" links="$links" checkboxes="$checkboxes" openTo="$!xcontext.macro.params.openTo" /}} links="$links" checkboxes="$checkboxes" openTo="#escapeMacroParam($xcontext.macro.params.openTo)" /}}
{{/velocity}}</code> {{/velocity}}</code>
</property> </property>
<property> <property>
......
...@@ -124,8 +124,10 @@ ...@@ -124,8 +124,10 @@
<property> <property>
<content>{{velocity}} <content>{{velocity}}
#panelheader($services.localization.render('xe.panels.navigation')) #panelheader($services.localization.render('xe.panels.navigation'))
## Escape special characters in macro parameter values.
#set ($openToDoc = $doc.documentReference.toString().replaceAll('([~"])', '~$1'))
{{documentTree showSpaces="true" showTranslations="false" showAttachments="false" {{documentTree showSpaces="true" showTranslations="false" showAttachments="false"
showChildDocuments="false" compact="true" openTo="document:$doc.documentReference" /}} showChildDocuments="false" compact="true" openTo="document:$openToDoc" /}}
#panelfooter() #panelfooter()
{{/velocity}}</content> {{/velocity}}</content>
</property> </property>
......
define(['jquery', 'JobRunner', 'jsTree'], function($, JobRunner) { define(['jquery', 'JobRunner', 'jsTree'], function($, JobRunner) {
// Fix the regular expression used by jsTree to escape special characters in CSS selectors. It is mainly used to be
// able to find a tree node by its id using Element#querySelector. We overwrite the default value used by jsTree in
// order to add the following special characters: ?`.
// TODO: Drop this after https://github.com/vakata/jstree/pull/914/ is merged.
$.jstree.idregex = /[\\:&!^|()\[\]<>@*'+~#";.,=\- \/${}%?`]/g;
var formToken = $('meta[name=form_token]').attr('content'); var formToken = $('meta[name=form_token]').attr('content');
var getNodeTypes = function(nodes) { var getNodeTypes = function(nodes) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment