Esempio n. 1
0
 def calculate_sanitized_body(self):
     plain_part, html_part = self.body
     # TODO: also strip signatures.
     if html_part:
         assert '\r' not in html_part, "newlines not normalized"
         extracted = extract_from_html(
             html_part.encode('utf-8')).decode('utf-8').strip()
         self.snippet = self.calculate_html_snippet(extracted)
         # If quote-stripping left us with a blank message, store the
         # original instead.
         if self.snippet.strip():
             self.sanitized_body = unicode(extracted)
         else:
             self.snippet = self.calculate_html_snippet(html_part)
             self.sanitized_body = html_part
     elif plain_part:
         extracted = extract_from_plain(plain_part).strip()
         if extracted.strip():
             self.snippet = self.calculate_plaintext_snippet(extracted)
             self.sanitized_body = plaintext2html(extracted, False)
         else:
             self.snippet = self.calculate_plaintext_snippet(plain_part)
             self.sanitized_body = plaintext2html(plain_part, False)
     else:
         self.sanitized_body = u''
         self.snippet = u''
Esempio n. 2
0
 def calculate_sanitized_body(self):
     plain_part, html_part = self.body
     # TODO: also strip signatures.
     if html_part:
         assert '\r' not in html_part, "newlines not normalized"
         extracted = extract_from_html(
             html_part.encode('utf-8')).decode('utf-8').strip()
         self.snippet = self.calculate_html_snippet(extracted)
         # If quote-stripping left us with a blank message, store the
         # original instead.
         if self.snippet.strip():
             self.sanitized_body = unicode(extracted)
         else:
             self.snippet = self.calculate_html_snippet(html_part)
             self.sanitized_body = html_part
     elif plain_part:
         extracted = extract_from_plain(plain_part).strip()
         if extracted.strip():
             self.snippet = self.calculate_plaintext_snippet(extracted)
             self.sanitized_body = plaintext2html(extracted, False)
         else:
             self.snippet = self.calculate_plaintext_snippet(plain_part)
             self.sanitized_body = plaintext2html(plain_part, False)
     else:
         self.sanitized_body = u''
         self.snippet = u''
Esempio n. 3
0
 def calculate_sanitized_body(self):
     plain_part, html_part = self.body
     # TODO: also strip signatures.
     if html_part:
         assert '\r' not in html_part, "newlines not normalized"
         stripped = extract_from_html(
             html_part.encode('utf-8')).decode('utf-8').strip()
         self.sanitized_body = unicode(stripped)
         self.calculate_html_snippet(self.sanitized_body)
     elif plain_part:
         stripped = extract_from_plain(plain_part).strip()
         self.sanitized_body = plaintext2html(stripped, False)
         self.calculate_plaintext_snippet(stripped)
     else:
         self.sanitized_body = u''
         self.snippet = u''