From ef5ff1630acbc33ee4a9571b913ada1996d2c4ad Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 30 Nov 2014 14:55:03 +0000 Subject: [PATCH] Textile: ignore invalid lang attribute values (#18501). git-svn-id: http://svn.redmine.org/redmine/trunk@13677 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- lib/redcloth3.rb | 4 ++-- .../wiki_formatting/textile_formatter_test.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/redcloth3.rb b/lib/redcloth3.rb index e11145077..032e8bd67 100644 --- a/lib/redcloth3.rb +++ b/lib/redcloth3.rb @@ -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!( /\(([^()]+?)\)/, '' ) diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 7a58d821d..d331dc28e 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -110,6 +110,20 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase ) end + def test_lang_attribute + assert_html_output( + '*[fr]French*' => 'French', + '*[fr-fr]French*' => 'French', + '*[fr_fr]French*' => 'French' + ) + end + + def test_lang_attribute_should_ignore_invalid_value + assert_html_output( + '*[fr3]French*' => '[fr3]French' + ) + end + def test_nested_lists raw = <<-RAW # Item 1 -- 2.39.5