Merge pull request #86 from dougkeen/master
Fix #85 (exception when stripping gmail quotes)
This commit is contained in:
@@ -78,7 +78,7 @@ def delete_quotation_tags(html_note, counter, quotation_checkpoints):
|
|||||||
def cut_gmail_quote(html_message):
|
def cut_gmail_quote(html_message):
|
||||||
''' Cuts the outermost block element with class gmail_quote. '''
|
''' Cuts the outermost block element with class gmail_quote. '''
|
||||||
gmail_quote = html_message.cssselect('div.gmail_quote')
|
gmail_quote = html_message.cssselect('div.gmail_quote')
|
||||||
if gmail_quote and not RE_FWD.match(gmail_quote[0].text):
|
if gmail_quote and (gmail_quote[0].text is None or not RE_FWD.match(gmail_quote[0].text)):
|
||||||
gmail_quote[0].getparent().remove(gmail_quote[0])
|
gmail_quote[0].getparent().remove(gmail_quote[0])
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,17 @@ def test_gmail_quote():
|
|||||||
RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body)))
|
RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body)))
|
||||||
|
|
||||||
|
|
||||||
|
def test_gmail_quote_compact():
|
||||||
|
msg_body = 'Reply' \
|
||||||
|
'<div class="gmail_quote">' \
|
||||||
|
'<div class="gmail_quote">On 11-Apr-2011, at 6:54 PM, Bob <bob@example.com> wrote:' \
|
||||||
|
'<div>Test</div>' \
|
||||||
|
'</div>' \
|
||||||
|
'</div>'
|
||||||
|
eq_("<html><body><p>Reply</p></body></html>",
|
||||||
|
RE_WHITESPACE.sub('', quotations.extract_from_html(msg_body)))
|
||||||
|
|
||||||
|
|
||||||
def test_gmail_quote_blockquote():
|
def test_gmail_quote_blockquote():
|
||||||
msg_body = """Message
|
msg_body = """Message
|
||||||
<blockquote class="gmail_quote">
|
<blockquote class="gmail_quote">
|
||||||
|
|||||||
Reference in New Issue
Block a user