def process_mail_listing(self): """ Search for a listing in this page """ current_folder = None for td in self.parser.root.search("td"): if td.attributes.get('align')=='left' and \ "Current Folder" in td.children[0]: current_folder = HTML.decode(td.children[1].innerHTML()) break if not current_folder: return None for table in self.parser.root.search("table"): ## I wish they would use css - it would make it easier to identify things: if table.attributes.get('cellpadding')=='1' and \ table.attributes.get('cellspacing')=='0' and \ table.attributes.get('border')=='0' and \ table.attributes.get('align')=='center' and \ table.attributes.get('bgcolor')=='#ffffcc': b = table.find("b") if b.innerHTML() == "From": ## Ok we are pretty sure this is a listing now: result = {'type':'Listed', 'Message': table, 'From': current_folder} return self.insert_message(result, inode_template = "y%s")
def stats(self, query, result): result.start_table(**{'class': 'GeneralTable'}) dbh = DB.DBO(self.case) columns = [ "service", "type", "From", "To", "CC", "BCC", "sent", "subject", "message" ] dbh.execute("select * from webmail_messages where `inode_id`=%r", self.lookup_id()) row = dbh.fetch() dbh2 = DB.DBO(self.case) dbh2.execute("select * from inode where inode_id = %r", row['inode_id']) row2 = dbh2.fetch() result.row("Timestamp", row2['mtime']) for c in columns: if c == 'message': ## Filter the message out here: parser = HTML.HTMLParser(tag_class = \ FlagFramework.Curry(HTML.ResolvingHTMLTag, case = self.case, inode_id = row['parent_inode_id'])) #parser = HTML.HTMLParser(tag_class = HTML.TextTag) parser.feed(HTML.decode(row[c] or "")) parser.close() #tmp = result.__class__(result) #tmp.text(parser.root.innerHTML(), font='typewriter', wrap='full') #row[c] = tmp r = parser.root.__str__() r = textwrap.fill(r) row[c] = r
def process_mail_listing(self): """ Search for a listing in this page """ current_folder = None for td in self.parser.root.search("td"): if td.attributes.get('align')=='left' and \ "Current Folder" in td.children[0]: current_folder = HTML.decode(td.children[1].innerHTML()) break if not current_folder: return None for table in self.parser.root.search("table"): ## I wish they would use css - it would make it easier to identify things: if table.attributes.get('cellpadding')=='1' and \ table.attributes.get('cellspacing')=='0' and \ table.attributes.get('border')=='0' and \ table.attributes.get('align')=='center' and \ table.attributes.get('bgcolor')=='#ffffcc': b = table.find("b") if b.innerHTML() == "From": ## Ok we are pretty sure this is a listing now: result = { 'type': 'Listed', 'Message': table, 'From': current_folder } return self.insert_message(result, inode_template="y%s")
def process_mail_listing(self): """ Search for a listing in this page """ current_folder = None for td in self.parser.root.search("td"): if td.attributes.get("align") == "left" and "Current Folder" in td.children[0]: current_folder = HTML.decode(td.children[1].innerHTML()) break if not current_folder: return None for table in self.parser.root.search("table"): ## I wish they would use css - it would make it easier to identify things: if ( table.attributes.get("cellpadding") == "1" and table.attributes.get("cellspacing") == "0" and table.attributes.get("border") == "0" and table.attributes.get("align") == "center" and table.attributes.get("bgcolor") == "#ffffcc" ): b = table.find("b") if b.innerHTML() == "From": ## Ok we are pretty sure this is a listing now: result = {"type": "Listed", "Message": table, "From": current_folder} return self.insert_message(result, inode_template="y%s")
def fixup_page(self, root, tag_class): ## We have to inject the message into the edit area: edit_area = root.find("div", {"class":"EditArea"}) or \ root.find("div",{"id":"MsgContainer"}) or \ root.find("textarea",{"id":"fMessageBody"}) if edit_area: parser = HTML.HTMLParser(tag_class=tag_class) parser.feed(HTML.decode(self.message)) #parser.feed(self.message) parser.close() result = parser.root.__str__() result = textwrap.fill(result) edit_area.prune() edit_area.add_child(result) edit_area.name = 'div'
def fixup_page(self, root, tag_class): ## We have to inject the message into the edit area: edit_area = root.find("div", {"class":"EditArea"}) or \ root.find("div",{"id":"MsgContainer"}) or \ root.find("textarea",{"id":"fMessageBody"}) if edit_area: parser = HTML.HTMLParser(tag_class = tag_class) parser.feed(HTML.decode(self.message)) #parser.feed(self.message) parser.close() result = parser.root.__str__() result = textwrap.fill(result) edit_area.prune() edit_area.add_child(result) edit_area.name = 'div'
def fixup_page(self, result, message, tag_class): """ Given the parse tree in root, fix up the page so it looks as close as possible to the way it should. We write the new page on outfd. """ if not message: return ## We have to inject the message into the edit area: edit_area = self.parser.root.find("div", {"class":"EditArea"}) or \ self.parser.root.find("div",{"id":"MsgContainer"}) or \ self.parser.root.find("textarea",{"id":"fMessageBody"}) if edit_area: parser = HTML.HTMLParser(tag_class=tag_class) parser.feed(HTML.decode(message)) parser.close() result = parser.root.__str__() result = textwrap.fill(result) edit_area.prune() edit_area.add_child(result) edit_area.name = 'div' return self.parser.root.innerHTML()
def fixup_page(self, result, message, tag_class): """ Given the parse tree in root, fix up the page so it looks as close as possible to the way it should. We write the new page on outfd. """ if not message: return ## We have to inject the message into the edit area: edit_area = self.parser.root.find("div", {"class":"EditArea"}) or \ self.parser.root.find("div",{"id":"MsgContainer"}) or \ self.parser.root.find("textarea",{"id":"fMessageBody"}) if edit_area: parser = HTML.HTMLParser(tag_class = tag_class) parser.feed(HTML.decode(message)) parser.close() result = parser.root.__str__() result = textwrap.fill(result) edit_area.prune() edit_area.add_child(result) edit_area.name = 'div' return self.parser.root.innerHTML()
def stats(self, query,result): result.start_table(**{'class':'GeneralTable'}) dbh = DB.DBO(self.case) columns = ["service","type","From","To","CC","BCC","sent","subject","message"] dbh.execute("select * from webmail_messages where `inode_id`=%r", self.lookup_id()) row = dbh.fetch() dbh2 = DB.DBO(self.case) dbh2.execute("select * from inode where inode_id = %r", row['inode_id']) row2 = dbh2.fetch() result.row("Timestamp", row2['mtime']) for c in columns: if c=='message': ## Filter the message out here: parser = HTML.HTMLParser(tag_class = \ FlagFramework.Curry(HTML.ResolvingHTMLTag, case = self.case, inode_id = row['parent_inode_id'])) #parser = HTML.HTMLParser(tag_class = HTML.TextTag) parser.feed(HTML.decode(row[c] or "")) parser.close() #tmp = result.__class__(result) #tmp.text(parser.root.innerHTML(), font='typewriter', wrap='full') #row[c] = tmp r = parser.root.__str__() r = textwrap.fill(r) row[c] = r result.row(c, row[c]) dbh.execute("select url from http where inode_id = %r", row['parent_inode_id']) row = dbh.fetch() if row: tmp = result.__class__(result) tmp.text(row['url'], font='typewriter', wrap='full') result.row("URL", tmp)