Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122083

Markdown writer fails to escape special characters

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2: Important P2: Important
    • 6.7.1, 6.8.0 FF
    • 5.15.2
    • GUI: Text handling
    • None
    • All
    • ca4774131 (dev), 106442586 (6.7), 0281005a7 (dev), 662dbcb8a (6.7)

      QTextMarkdownWriter fails to escape special characters at the beginnings of blocks, most notably '-', '*', '+' and '#' and generally fails to escape special characters like '\' and '`', causing ordinary characters to be treated as markup when reading back the generated markdown code.

      The failure to escape initial characters in a block is surprising, because there is code to escape the first character when wrapping text, which is a much less common case (see the static function maybeEscapeFirstChar and where it is called).

      The text "+ and - are arithmetic operations" is written out verbatim, so when it is read back in as markdown, it shows as a list item:

      • and - are arithmetic operations

      Similarly, when the text "# is next to 0 on your phone keypad" is read back as markdown, it is treated as a heading and looks like this:

      is next to 0 on your phone keypad

      The text "Use two backslashes <backslash><backslash> to separate fields." (with <backslash> replaced by a backslash character - ironically, the Jira visual editor does not allow me to enter two backslashes) is exported verbatim and when read back becomes:

      Use two backslashes \ to separate fields.

      I have tested this with Qt 5.15.2, but from looking at the source code, there seems to be no change since then, so I expect this to still be broken in the current Qt6 releases.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            srutledg Shawn Rutledge
            wuerthmn Martin Würthner
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes