From 8f3fe2b3992f14d95d08a27cca0d415be0c470f5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 21 Mar 2017 09:02:15 +0100 Subject: [PATCH] Fixed endless loop in HtmlSanitizer.cleanup_structure in certain conditions. --- lib/core_ext/string.rb | 2 +- lib/html_sanitizer.rb | 25 ++++++++++++++++++++----- test/unit/aaa_string_test.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 7564c067c..d7dd013f0 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -335,7 +335,7 @@ class String '(|

|

)[[:space:]]*(Von|From|De|от|Z|Od|Ze|Fra|Van|Mistä|Από|Dal|から|Из|од|iz|Från|จาก|з|Từ):[[:space:]]*', '(
|
)[[:space:]]*
[[:space:]]*(Von|From|De|от|Z|Od|Ze|Fra|Van|Mistä|Από|Dal|から|Из|од|iz|Från|จาก|з|Từ):[[:space:]]+', '[[:space:]]*
[[:space:]]*(On|Am|Le|El|Den|Dňa|W dniu|Il|Op|Dne|Dana)[[:space:]]', - '[[:space:]]*
[[:space:]]*(On|Am|Le|El|Den|Dňa|W dniu|Il|Op|Dne|Dana)[[:space:]].+?[[:space:]]*
[[:space:]]*(On|Am|Le|El|Den|Dňa|W dniu|Il|Op|Dne|Dana)[[:space:]].{1,500} ' assert_equal(result, html.html2html_strict) + + html = "
Dear Bob:Mr/Mrs

We are one of the leading manufacturer and supplier of conduits and cars since 3000.

Could you inform me the specification you need?

May I sent you our products catalogues for your reference?

Best regards!

Welcome to our booth B11/1 Hall 13 during SOMEWHERE\n9999.
Bob Smith
Exp. & Imp.
Town Example Electric Co., Ltd.
Tel: 0000-11-12345678 (Ext-220)  Fax: 0000-11-12345678 
Room1234, NO. 638, Smith Road, Town, 200000, Somewhere
Web: www.example.com
" + result = '
+
Dear Bob:Mr/Mrs
+
+
We are one of the leading manufacturer and supplier of conduits and cars since 3000.
+
+
Could you inform me the specification you need?
+
+
May I sent you our products catalogues for your reference?
+
+
+
Best regards!
+
+
Welcome to our booth B11/1 Hall 13 during SOMEWHERE 9999.
+
+
Bob Smith
+
+
Exp. & Imp.
+
Town Example Electric Co., Ltd.
+
Tel: 0000-11-12345678 (Ext-220) Fax: 0000-11-12345678
+
Room1234, NO. 638, Smith Road, Town, 200000, Somewhere
+ +
+
+
+
' + assert_equal(result, html.html2html_strict) + + end end