浏览代码

Clearly use html.parser as parser

Guénaël Muller 7 年前
父节点
当前提交
f38e9353a7

+ 2 - 1
tracim/tracim/lib/email_processing/models.py 查看文件

104
         # INFO - G.M - 2017-12-01 - Override part_type is elem has no content.
104
         # INFO - G.M - 2017-12-01 - Override part_type is elem has no content.
105
         # Choose last elem part_type instead of the proposed one.
105
         # Choose last elem part_type instead of the proposed one.
106
         if len(self._list) > 0:
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
             if not txt:
109
             if not txt:
109
                 value.part_type = self._list[-1].part_type
110
                 value.part_type = self._list[-1].part_type
110
         BodyMailParts._check_value(value)
111
         BodyMailParts._check_value(value)

+ 2 - 2
tracim/tracim/tests/library/test_email_body_parser.py 查看文件

15
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is True
15
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is True
16
 
16
 
17
     def test_unit__is_standard_quote_no(self):
17
     def test_unit__is_standard_quote_no(self):
18
-        soup = BeautifulSoup('<a></a>')
18
+        soup = BeautifulSoup('<a></a>', 'html.parser')
19
         main_elem = soup.find()
19
         main_elem = soup.find()
20
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is False
20
         assert HtmlMailQuoteChecker._is_standard_quote(main_elem) is False
21
 
21
 
26
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is True
26
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is True
27
 
27
 
28
     def test_unit__is_thunderbird_quote_no(self):
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
         main_elem = soup.find()
30
         main_elem = soup.find()
31
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is False
31
         assert HtmlMailQuoteChecker._is_thunderbird_quote(main_elem) is False
32
 
32