This issue has been created
There is 1 update.
 
 
XWiki Rendering / cid:jira-generated-image-avatar-962aa814-593b-4e6a-b44a-077217b01749 XRENDERING-814 Open

Support supplementary characters when validating XML names

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-4e9a17b6-c6cb-4388-95d2-77e23c2a1623 Vincent Massol created this issue on 02/Sep/26 15:15
 
Summary: Support supplementary characters when validating XML names
Issue Type: cid:jira-generated-image-avatar-962aa814-593b-4e6a-b44a-077217b01749 Improvement
Assignee: Unassigned
Components: Wikimodel
Created: 02/Sep/26 15:15
Priority: cid:jira-generated-image-static-major-e16e84f8-6164-4c10-bd0a-bbcb4492c36c Major
Reporter: Vincent Massol
Description:

Problem

WikiPageUtil exposes its XML name validation through two char based methods:

public static boolean isValidXmlNameChar(char ch, boolean colonEnabled)
public static boolean isValidXmlNameStartChar(char ch, boolean colonEnabled)

A char is a UTF-16 code unit, so it can only carry values in the range 0x0000-0xFFFF. The XML NameStartChar production however also allows the supplementary range #x10000-#xEFFFF, and isValidXmlNameStartChar does try to accept it with a final (ch >= 0x10000 && ch <= 0xEFFFF) alternative. That alternative can never hold for a char argument, which SonarQube reports as two java:S2198 issues ("will always return false" and "will always return true").

The consequence is not only dead code. A supplementary character reaches these methods as a surrogate pair, and each surrogate taken on its own (0xD800-0xDFFF) is rejected by every alternative. So isValidXmlName reports a perfectly valid XML name such as U+20000 followed by "foo" as invalid.

Proposal

Add int code point based overloads, which can express the whole production:

public static boolean isValidXmlNameChar(int codePoint, boolean colonEnabled)
public static boolean isValidXmlNameStartChar(int codePoint, boolean colonEnabled)

and make isValidXmlName(String, boolean) walk the string by code point instead of by char, so that a supplementary character is validated as the single character it is.

Deprecate the char overloads and move them to a new xwiki-rendering-legacy-wikimodel backward compatibility module, so that the main artifact only exposes the code point based API while extensions compiled against the char signatures keep working.

 
 

1 update

 
cid:jira-generated-image-avatar-4e9a17b6-c6cb-4388-95d2-77e23c2a1623 Changes by Vincent Massol on 02/Sep/26 15:15
 
Fix Version: 18.8.0-rc-1