diff --git a/src/bitmessageqt/messageview.py b/src/bitmessageqt/messageview.py index a579dd13..66aac2cb 100644 --- a/src/bitmessageqt/messageview.py +++ b/src/bitmessageqt/messageview.py @@ -1,5 +1,6 @@ from PyQt4 import QtCore, QtGui +from urlparse import urlparse from safehtmlparser import * class MessageView(QtGui.QTextBrowser): @@ -42,6 +43,16 @@ class MessageView(QtGui.QTextBrowser): QtGui.QApplication.activeWindow().statusBar().showMessage(QtGui.QApplication.translate("MainWindow", "Zoom level %1%").arg(str(zoom))) def confirmURL(self, link): + if link.scheme() == "mailto": + QtGui.QApplication.activeWindow().ui.lineEditTo.setText(link.path()) + if link.hasQueryItem("subject"): + QtGui.QApplication.activeWindow().ui.lineEditSubject.setText(link.queryItemValue("subject")) + if link.hasQueryItem("body"): + QtGui.QApplication.activeWindow().ui.textEditMessage.setText(link.queryItemValue("body")) + QtGui.QApplication.activeWindow().ui.tabWidgetSend.setCurrentIndex(0) + QtGui.QApplication.activeWindow().ui.tabWidget.setCurrentIndex(1) + QtGui.QApplication.activeWindow().ui.textEditMessage.setFocus() + return reply = QtGui.QMessageBox.warning(self, QtGui.QApplication.translate(type(self).__name__, MessageView.CONFIRM_TITLE), QtGui.QApplication.translate(type(self).__name__, MessageView.CONFIRM_TEXT).arg(str(link.toString())), diff --git a/src/bitmessageqt/safehtmlparser.py b/src/bitmessageqt/safehtmlparser.py index 79ad0f73..78f89888 100644 --- a/src/bitmessageqt/safehtmlparser.py +++ b/src/bitmessageqt/safehtmlparser.py @@ -1,5 +1,6 @@ from HTMLParser import HTMLParser import inspect +import re from urllib import quote, quote_plus from urlparse import urlparse @@ -20,6 +21,9 @@ class SafeHTMLParser(HTMLParser): 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'var', 'video'] replaces = [["&", "&"], ["\"", """], ["<", "<"], [">", ">"], ["\n", "
"], ["\t", "    "], [" ", "  "], [" ", "  "], ["
", "
 "]] src_schemes = [ "data" ] + uriregex1 = re.compile(r'(\b(?:https?|telnet|gopher|file|wais|ftp):[\w/#~:.?+=&%@!\-.:;?\\-]+?(?=[.:?\-]*(?:[^\w/#~:;.?+=&%@!\-.:?\-]|$)))') + uriregex2 = re.compile(r'\1', + unicode(tmp, 'utf-8', 'replace')) + tmp = SafeHTMLParser.uriregex2.sub(r'\1', tmp) + self.raw += tmp def is_html(self, text = None, allow_picture = False): if text: