Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xwiki-platform
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XWiki
xwiki-platform
Commits
3c93eec5
Commit
3c93eec5
authored
7 months ago
by
Marius Dumitru Florea
Browse files
Options
Downloads
Patches
Plain Diff
XWIKI-22326: "newline" special character in page name breaks the navigation tree
parent
603d4fce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xwiki-platform-core/xwiki-platform-tree/xwiki-platform-tree-webjar/src/main/webjar/tree.js
+18
-5
18 additions, 5 deletions
...m-tree/xwiki-platform-tree-webjar/src/main/webjar/tree.js
with
18 additions
and
5 deletions
xwiki-platform-core/xwiki-platform-tree/xwiki-platform-tree-webjar/src/main/webjar/tree.js
+
18
−
5
View file @
3c93eec5
...
...
@@ -29,11 +29,24 @@ define([
// jsTree uses the underscore notation for its API, instead of camel case.
// jshint camelcase:false,maxstatements:false
// 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:
// * \s (any white space character, such as non breaking space, not just the plain space)
$
.
jstree
.
idregex
=
/
[\\
:&!^|()
\[\]
<>@*'+~#";.,=
\-\s\/
${}%?`
]
/g
;
// jsTree node identifiers are used without any escaping in HTML id attributes. When finding the DOM node associated
// with a jsTree node, the jsTree node identifier needs to be escaped in order to avoid breaking the CSS selector
// used. Instead of using CSS.escape(), jsTree performs its own custom CSS escaping, based on a regular expression.
// This regular expression doesn't include all the special characters (e.g. doesn't escape all white space characters,
// such as non-breaking space) and doesn't handle well new line and line feed characters which need special treatment.
// For this reason we overwrite the String.replace() function to perform CSS escaping when the passed arguments are
// the jsTree ID regular expression and the escape string.
// FIXME: Drop this hack when jsTree replaces its custom CSS escaping code with CSS.escape().
if
(
$
.
jstree
.
idregex
)
{
const
originalStringReplace
=
String
.
prototype
.
replace
;
String
.
prototype
.
replace
=
function
(...
args
)
{
if
(
args
[
1
]
===
'
\\
$&
'
&&
args
[
0
]
===
$
?.
jstree
?.
idregex
)
{
return
CSS
.
escape
(
this
);
}
else
{
return
originalStringReplace
.
apply
(
this
,
args
);
}
};
}
var
formToken
=
$
(
'
meta[name=form_token]
'
).
attr
(
'
content
'
);
...
...
This diff is collapsed.
Click to expand it.
Git Mirror User
@gitmirror
mentioned in commit
58c11bd8
·
7 months ago
mentioned in commit
58c11bd8
mentioned in commit 58c11bd8cf153c088b07f9148d44cb6c62f47123
Toggle commit list
Git Mirror User
@gitmirror
mentioned in commit
f285dd82
·
7 months ago
mentioned in commit
f285dd82
mentioned in commit f285dd8289cb56d2cf1dd529713b3bd91d0477e1
Toggle commit list
Git Mirror User
@gitmirror
mentioned in commit
21bc7a2e
·
7 months ago
mentioned in commit
21bc7a2e
mentioned in commit 21bc7a2e33f2219b11da19fae43df3ac84912ab9
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment