Esempio n. 1
0
def get_temp_proofs(ticket, only_urls=False):
    """
        Get report's ticket content
    """
    temp_proofs = []
    for report in ticket.reportTicket.all():
        if only_urls:
            content = '\n'.join([item.rawItem for item in report.reportItemRelatedReport.filter(itemType='URL')])
        else:
            content = 'From: %s\nDate: %s\nSubject: %s\n\n%s\n'
            content = content % (
                report.provider.email,
                report.receivedDate.strftime("%d/%m/%y %H:%M"),
                report.subject,
                utils.dehtmlify(report.body)
            )
        for email in re.findall(regexp.EMAIL, content):  # Remove potentially sensitive emails
            content = content.replace(email, '*****@*****.**')
        temp_proofs.append(
            Proof.objects.create(
                content=content,
                ticket=report.ticket,
            )
        )
    return temp_proofs
Esempio n. 2
0
    def test_dehtmlify(self):

        # No need to cover all html2text lib
        content = '<html><body>test\r\ntest<img src ...../></body></html>'
        content = utils.dehtmlify(content)
        self.assertIn('test', content)
        self.assertNotIn('img', content)
        self.assertNotIn('<', content)