Defect #35765

Code with unsupported code language is not render when CommonMark Markdown is used

Added by Marius BALTEANU 3 months ago. Updated 3 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Marius BALTEANU% Done:

0%

Category:Text formatting
Target version:-
Resolution:Fixed Affected version:

Description

The following code snippet:

```phpvb
<?php

echo "This is with unsupported code!";

is render as following:

In textile and classic Markdown, the code is rendered without any syntax highlight (as exppected).

empty.png (19.4 KB) Marius BALTEANU, 2021-08-15 13:13


Related issues

Related to Redmine - Feature #32424: CommonMark Markdown Text Formatting Closed

Associated revisions

Revision 21181
Added by Marius BALTEANU 3 months ago

Preserve the code block and remove the class from it when the language is not supported in CommonMark formatter (#35765, 32424).

History

#1 Updated by Marius BALTEANU 3 months ago

  • Related to Feature #32424: CommonMark Markdown Text Formatting added

#2 Updated by Marius BALTEANU 3 months ago

  • Category set to Text formatting

#3 Updated by Marius BALTEANU 3 months ago

The following patch should fix this

iff --git a/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter.rb b/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter.rb
index a027e6a17..c7c43ee8b 100644
--- a/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter.rb
+++ b/lib/redmine/wiki_formatting/common_mark/syntax_highlight_filter.rb
@@ -39,7 +39,7 @@ module Redmine
               node["class"] = "#{lang} syntaxhl" 
             else
               # unsupported language, strip out the code tag
-              node.parent.inner_html = text
+              node.parent.inner_html = CGI.escapeHTML(text)
             end
           end
           doc

but also the unified code blocks proposed by Martin in #35104 and #32424#note-39 should do the trick.

#4 Updated by Marius BALTEANU 3 months ago

  • Status changed from New to Closed

Fixed in r21181.

Now we render the code block even if the language is not supported, but we remove the class attribute.

#5 Updated by Marius BALTEANU 3 months ago

  • Resolution set to Fixed

Also available in: Atom PDF