]> source.dussan.org Git - redmine.git/commitdiff
Textile: ignore invalid lang attribute values (#18501).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 30 Nov 2014 14:55:03 +0000 (14:55 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 30 Nov 2014 14:55:03 +0000 (14:55 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13677 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redcloth3.rb
test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb

index e11145077d1bb3db1a9c206e1c0dfde6f02336ad..032e8bd678ad9029ba22aa5c7fbc243824817282 100644 (file)
@@ -341,7 +341,7 @@ class RedCloth3 < String
     A_HLGN = /(?:(?:<>|<|>|\=|[()]+)+)/
     A_VLGN = /[\-^~]/
     C_CLAS = '(?:\([^")]+\))'
-    C_LNGE = '(?:\[[^"\[\]]+\])'
+    C_LNGE = '(?:\[[a-z\-_]+\])'
     C_STYL = '(?:\{[^"}]+\})'
     S_CSPN = '(?:\\\\\d+)'
     S_RSPN = '(?:/\d+)'
@@ -480,7 +480,7 @@ class RedCloth3 < String
         end
 
         lang = $1 if
-            text.sub!( /\[([^)]+?)\]/, '' )
+            text.sub!( /\[([a-z\-_]+?)\]/, '' )
 
         cls = $1 if
             text.sub!( /\(([^()]+?)\)/, '' )
index 7a58d821d7e22592853b19f97ee480256b9c0390..d331dc28e96faa085fbeb1c9a9e1327e62537696 100644 (file)
@@ -110,6 +110,20 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase
     )
   end
 
+  def test_lang_attribute
+    assert_html_output(
+      '*[fr]French*'      => '<strong lang="fr">French</strong>',
+      '*[fr-fr]French*'   => '<strong lang="fr-fr">French</strong>',
+      '*[fr_fr]French*'   => '<strong lang="fr_fr">French</strong>'
+    )
+  end
+
+  def test_lang_attribute_should_ignore_invalid_value
+    assert_html_output(
+      '*[fr3]French*'      => '<strong>[fr3]French</strong>'
+    )
+  end
+
   def test_nested_lists
     raw = <<-RAW
 # Item 1