Anchor name can invalidly include spaces
Type of report
Bug
Provide detailed reproduction steps (if any)
- Start with CodePen https://codepen.io/karoldawidziuk/pen/LYzJvdx.
- Select "Please find below the full schedule of the event."
- Copy that string of text.
- Click the Anchor icon.
- In the Anchor Name field, paste the entire string of text.
- Click OK.
Expected result
Option 1. Get error message that the anchor name includes whitespace. Option 2. Continue here and see option 2 expected result below.
Actual result
Continue here without error message.
Reproduction steps continued
- Scroll to top of edit area
- Select the words "The Flavorful Tuscany Meetup"
- Click the link icon
- Change Link type to Link to anchor in the text
- Click the down arrow in the By Element ID dropdown
Expected result
Option 2: See dropdown item "Please_find_below_the_full_schedule_of_the_event." or "Pleasefindbelowthefullscheduleoftheevent."
Actual result
See dropdown item "Please find below the full schedule of the event."
Other details
-
Browser: Firefox 103.0.1
-
OS: macOS 12.5
-
CKEditor version: Whichever version is used by CodePen https://codepen.io/karoldawidziuk/pen/LYzJvdx on August 3, 2022.
-
Installed CKEditor plugins: Whichever plugins are used by CodePen https://codepen.io/karoldawidziuk/pen/LYzJvdx on August 3, 2022.
-
Standard cited for this issue: HTML 5.2 Recommendation concerning the ID attribute.
When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element’s tree and must contain at least one character. The value must not contain any space characters.
The cited spec forbids the following characters in an id attribute:
- U+0020 SPACE,
- U+0009 CHARACTER TABULATION (tab),
- U+000A LINE FEED (LF),
- U+000C FORM FEED (FF), and
- U+000D CARRIAGE RETURN (CR).
Therefore any of these using in the Anchor Name field need to be stripped or replaced with a permitted character.
I can confirm the issue.
We can resolve that issue by adding validation to the anchor dialog that it's not possible to add IDs with spaces.
Worth to check: https://github.com/ckeditor/ckeditor4/issues/1666
Closed in https://github.com/ckeditor/ckeditor4/pull/5362