diff options
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-09-30 11:46:27 +0200 |
---|---|---|
committer | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> | 2018-09-30 11:46:27 +0200 |
commit | 1965abf99abdba6ee9882b21541dc15b5f271c8e (patch) | |
tree | c4a9f263bee53f797c2c4bafaea5b033e156dfe0 | |
parent | c13ae1b932947dd102f8e3b20492a885f14a8198 (diff) | |
download | poezio-1965abf99abdba6ee9882b21541dc15b5f271c8e.tar.gz poezio-1965abf99abdba6ee9882b21541dc15b5f271c8e.tar.bz2 poezio-1965abf99abdba6ee9882b21541dc15b5f271c8e.tar.xz poezio-1965abf99abdba6ee9882b21541dc15b5f271c8e.zip |
XEP-0231: Extract cids from XHTML-IM.
-rw-r--r-- | poezio/xhtml.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/poezio/xhtml.py b/poezio/xhtml.py index fefa2e1b..899985ef 100644 --- a/poezio/xhtml.py +++ b/poezio/xhtml.py @@ -186,6 +186,7 @@ whitespace_re = re.compile(r'\s+') xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]') xhtml_data_re = re.compile(r'data:image/([a-z]+);base64,(.+)') +xhtml_cid_re = re.compile(r'^cid:(sha1\+[0-9a-fA-F]+@bob\.xmpp\.org)$') poezio_color_double = re.compile(r'(?:\x19\d+}|\x19\d)+(\x19\d|\x19\d+})') poezio_format_trim = re.compile(r'(\x19\d+}|\x19\d|\x19[buaio]|\x19o)+\x19o') @@ -305,6 +306,7 @@ class XHTMLHandler(sax.ContentHandler): self.formatting = [] # type: List[str] self.attrs = [] # type: List[Dict[str, str]] self.list_state = [] # type: List[Union[str, int]] + self.cids = {} # type: Dict[str, Optional[str]] self.is_pre = False self.a_start = 0 # do not care about xhtml-in namespace @@ -376,6 +378,12 @@ class XHTMLHandler(sax.ContentHandler): builder.append('[Error while saving image: %s]' % e) else: builder.append('[file stored as %s]' % filename) + elif re.match(xhtml_cid_re, + attrs['src']) and self.tmp_image_dir is not None: + cid = attrs['src'][4:] + # TODO: start the download outside of this parser. + self.cids[cid] = None + builder.append('[Error: XEP-0231 file transfer not yet supported]') else: builder.append(_trim(attrs['src'])) if 'alt' in attrs: |