ckeditor4 icon indicating copy to clipboard operation
ckeditor4 copied to clipboard

Anchor name can invalidly include spaces

Open CharlesBelov opened this issue 3 years ago • 4 comments

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Start with CodePen https://codepen.io/karoldawidziuk/pen/LYzJvdx.
  2. Select "Please find below the full schedule of the event."
  3. Copy that string of text.
  4. Click the Anchor icon.
  5. In the Anchor Name field, paste the entire string of text.
  6. 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

  1. Scroll to top of edit area
  2. Select the words "The Flavorful Tuscany Meetup"
  3. Click the link icon
  4. Change Link type to Link to anchor in the text
  5. 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.

CharlesBelov avatar Aug 03 '22 23:08 CharlesBelov

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.

CharlesBelov avatar Aug 03 '22 23:08 CharlesBelov

I can confirm the issue.

Comandeer avatar Aug 04 '22 12:08 Comandeer

We can resolve that issue by adding validation to the anchor dialog that it's not possible to add IDs with spaces.

jacekbogdanski avatar Aug 10 '22 08:08 jacekbogdanski

Worth to check: https://github.com/ckeditor/ckeditor4/issues/1666

sculpt0r avatar Aug 10 '22 08:08 sculpt0r

Closed in https://github.com/ckeditor/ckeditor4/pull/5362

CKEditorBot avatar Nov 21 '22 17:11 CKEditorBot