]> source.dussan.org Git - redmine.git/commitdiff
Fix: Syntax highlighter does not work if language name is single-quoted (#28469).
authorGo MAEDA <maeda@farend.jp>
Wed, 2 May 2018 02:27:10 +0000 (02:27 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 2 May 2018 02:27:10 +0000 (02:27 +0000)
Patch by Mizuki ISHIKAWA.

git-svn-id: http://svn.redmine.org/redmine/trunk@17322 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/wiki_formatting/textile/formatter.rb
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb

index 63851a21a5ae4cbcb8798af4eed23db1eede0f2a..6e7f28e621ad3d1d58584e3a9c73ec1d92415fd6 100644 (file)
@@ -120,7 +120,7 @@ module Redmine
             ## replace <pre> content
             text.gsub!(/<redpre#(\d+)>/) do
               content = @pre_list[$1.to_i]
-              if content.match(/<code\s+class="(\w+)">\s?(.+)/m)
+              if content.match(/<code\s+class=["'](\w+)["']>\s?(.+)/m)
                 language = $1
                 text = $2
                 if Redmine::SyntaxHighlighting.language_supported?(language)
index 059f0b83a0c9ef9d273d811a048ce7c1b93607f6..712bc5000f9ffbdcd81ebfc4ca388b5ce92c436a 100644 (file)
@@ -546,7 +546,10 @@ STR
   end
 
   def test_should_allow_valid_language_class_attribute_on_code_tags
+    # language name is double-quoted
     assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
+    # language name is single-quoted
+    assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
   end
 
   def test_should_not_allow_valid_language_class_attribute_on_non_code_offtags