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
- In a CKEditor field, select existing text.
- Add a link to a PDF/file.
- Open Advanced Link Options.
- Enable “Download”.
- Save the entry.
- 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
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 isdownload="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 istrueto an empty string. The non-collapsed/range branch does not apply the same normalization and passesextraAttributeValues[item.model]directly towriter.setAttribute(...).Steps to reproduce
Additional info
Related issue: #551