Bladeren bron

Clearly use html.parser as parser

Guénaël Muller 6 jaren geleden
bovenliggende
commit
f38e9353a7

+ 2 - 1
tracim/tracim/lib/email_processing/models.py Bestand weergeven

@@ -104,7 +104,8 @@ class HtmlBodyMailParts(BodyMailParts):
104 104
         # INFO - G.M - 2017-12-01 - Override part_type is elem has no content.
105 105
         # Choose last elem part_type instead of the proposed one.
106 106
         if len(self._list) > 0:
107
-            txt = BeautifulSoup(value.text).get_text().replace('\n','').strip()
107
+            txt = BeautifulSoup(value.text, 'html.parser').get_text()
108
+            txt = txt.replace('\n', '').strip()
108 109
             if not txt:
109 110
                 value.part_type = self._list[-1].part_type
110 111
         BodyMailParts._check_value(value)

+ 2 - 2
tracim/tracim/tests/library/test_email_body_parser.py Bestand weergeven

@@ -15,7 +15,7 @@ class TestHtmlMailQuoteChecker(TestStandard):
15 15
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is True
16 16
 
17 17
     def test_unit__is_standard_quote_no(self):
18
-        soup = BeautifulSoup('<a></a>')
18
+        soup = BeautifulSoup('<a></a>', 'html.parser')
19 19
         main_elem = soup.find()
20 20
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is False
21 21
 
@@ -26,7 +26,7 @@ class TestHtmlMailQuoteChecker(TestStandard):
26 26
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is True
27 27
 
28 28
     def test_unit__is_thunderbird_quote_no(self):
29
-        soup = BeautifulSoup('<div class="nothing"></div>')
29
+        soup = BeautifulSoup('<div class="nothing"></div>', 'html.parser')
30 30
         main_elem = soup.find()
31 31
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is False
32 32