Skip to content

Download advanced link option saves download="true" for selected text links #606

Description

@alexkuzmin

Description

When using CKEditor’s Advanced Link Options and enabling “Download” for a link created from selected text, the saved HTML contains:

<a href="/file.pdf" download="true">Download file</a>

This looks related to #551, but it is not exactly the same issue.

#551 was about download="download". In this case the saved value is download="true".

It also appears to happen specifically when creating/updating a link from selected text. The collapsed-cursor path seems to normalize boolean advanced link attributes correctly, but the selected-text/range path keeps the raw boolean value.

In _adjustLinkCommand(), the collapsed-selection branch normalizes boolean advanced link attributes whose configured value is true to an empty string. The non-collapsed/range branch does not apply the same normalization and passes extraAttributeValues[item.model] directly to writer.setAttribute(...).

Steps to reproduce

  1. In a CKEditor field, select existing text.
  2. Add a link to a PDF/file.
  3. Open Advanced Link Options.
  4. Enable “Download”.
  5. Save the entry.
  6. Inspect the saved/rendered HTML or download the file.

Additional info

  • Craft version: 5.10.8.1
  • PHP version: 8.3
  • Database driver & version: MySQL 8.0.x
  • Plugins & versions: CKEditor 5.6.1

Related issue: #551

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions