Skip to content

In rich text editor, links are over-zealously escaped in the resulting markdown on save

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Problem to solve

As reported in #332629 (comment 745539518), Cyrillic characters written in the Content Editor or read from existing pages get replaced with URL-encoded strings.

Steps to reproduce

  1. Using the plain text editor, add the following markdown to a comment or an issue:
# пример заголовка

[link to this header](#пример-заголовка)
  1. Switch to rich text editor. Change the link text to something else.
  2. Switch back to plain text editor.
  3. Notice the URL in the link is escaped
# пример заголовка

[link to this header](#%D0%BF%D1%80%D0%B8%D0%BC%D0%B5%D1%80-%D0%B7%D0%B0%D0%B3%D0%BE%D0%BB%D0%BE%D0%B2%D0%BA%D0%B0) test

Video

CleanShot 2025-04-10 at 18.19.49.mp4

Implementation guide

In app/assets/javascripts/content_editor/services/serialization_helpers.js, lines 660 and 667, we use state.esc to escape the URL of the link when serializing prosemirror content to markdown. This was copied from original implementation of prosemirror-markdown, but that implementation has since changed.

We need to remove state.esc instances mentioned above, and do an implementation similar to upstream.

Tests need to be added/updated in spec/frontend/content_editor/services/markdown_serializer_spec.js.

Edited by 🤖 GitLab Bot 🤖