This issue has been created
There is 1 update.
 
 
XWiki Platform / cid:jira-generated-image-avatar-2fadd6bd-1cd8-4369-bfa6-62b1d39bd325 XWIKI-24834 Open

Creating a link to a new page by selecting text and validating the link dialog produces an empty link target

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-1e6f78bc-f28f-4954-9b25-9ba36d1c0842 Vincent Massol created this issue on 08/Sep/26 19:31
 
Summary: Creating a link to a new page by selecting text and validating the link dialog produces an empty link target
Issue Type: cid:jira-generated-image-avatar-2fadd6bd-1cd8-4369-bfa6-62b1d39bd325 Bug
Affects Versions: 18.2.0-rc-1
Assignee: Unassigned
Components: CKEditor, WYSIWYG Editor
Created: 08/Sep/26 19:31
Labels: regression
Priority: cid:jira-generated-image-static-critical-913d2ad9-4883-422e-80d4-d1d6afb8423c Critical
Reporter: Vincent Massol
Description:

Steps to reproduce

  1. Edit a page with the WYSIWYG editor (CKEditor).
  2. Type some text, e.g. Test.
  3. Select that text and open the link dialog (toolbar button or Ctrl+K).
  4. Leave the Page field untouched and validate the dialog.
  5. Save the page.

Actual result

The link has an empty target, so it points to the page itself:

[[Test>>]]

Nothing warns the user, and the only way out is to edit the wiki source.

Expected result

A link to a new page named after the selected text, as before 18.2.0:

[[Test>>doc:Test.WebHome]]

Cause

Regression of XWIKI-22508 caused by XWIKI-24119. Confirmed by Marius.

Until 18.1.x, opening the link dialog with a text selection pre-filled the Page field with a new-page reference computed from the selected text by CKEditor.LinkNameStrategyHelper (getDefaultResourceReference() and setDefaultValue() in xwiki-link/plugin.js, added by XWIKI-22508), so validating the dialog without touching anything created the link to the new page.

XWIKI-24119 removed that pre-fill, and the field now opens empty:

setup: function(data) {
  let resourceReference = data.resourceReference;
  if (!resourceReference) {
    // We're probably creating a new link so there's no resource to preselect.
    return;

The empty target is not rejected either, because of a second problem: in xwiki-resource/plugin.js, validate() accepts an empty reference as soon as the resource type declares allowEmptyReference, which the doc type does (in resource/resource.js) - legitimately, since that is what allows anchor-only links such as:

[[label>>||anchor=Section]]

As a result the mustBeSelected check added by XWIKI-23154 sits in the else if branch and is never reached for an empty field, so the dialog validates silently.

No functional test covers "select text, open the link dialog, validate", which is why the removal went unnoticed.

Workaround

Type the page name in the Page field and select "Create new page..." (or "Create with exact reference...") from the suggestions; typed text alone is discarded by the suggest widget. The page-creation node of the tree picker also works.

To be decided

Marius: pre-filling the suggest (preselecting a value based on the link label) is fine, but we need to decide between "Create with exact reference" and "Create new page" (relative to the current location), the two options offered when you type the link label yourself in the suggest input.

Independently of that choice, the empty-reference validation for the doc type should probably be tightened so that an empty reference is only accepted when an anchor or a query string is set, otherwise this silent self-link stays reachable.

 
 

1 update

 
cid:jira-generated-image-avatar-1e6f78bc-f28f-4954-9b25-9ba36d1c0842 Changes by Vincent Massol on 08/Sep/26 19:34
 
Assignee: Marius Dumitru Florea