XEP-0231: Extract cids from XHTML-IM.
This commit is contained in:
parent
c13ae1b932
commit
1965abf99a
1 changed files with 8 additions and 0 deletions
|
@ -186,6 +186,7 @@ whitespace_re = re.compile(r'\s+')
|
||||||
|
|
||||||
xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]')
|
xhtml_attr_re = re.compile(r'\x19-?\d[^}]*}|\x19[buaio]')
|
||||||
xhtml_data_re = re.compile(r'data:image/([a-z]+);base64,(.+)')
|
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_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')
|
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.formatting = [] # type: List[str]
|
||||||
self.attrs = [] # type: List[Dict[str, str]]
|
self.attrs = [] # type: List[Dict[str, str]]
|
||||||
self.list_state = [] # type: List[Union[str, int]]
|
self.list_state = [] # type: List[Union[str, int]]
|
||||||
|
self.cids = {} # type: Dict[str, Optional[str]]
|
||||||
self.is_pre = False
|
self.is_pre = False
|
||||||
self.a_start = 0
|
self.a_start = 0
|
||||||
# do not care about xhtml-in namespace
|
# do not care about xhtml-in namespace
|
||||||
|
@ -376,6 +378,12 @@ class XHTMLHandler(sax.ContentHandler):
|
||||||
builder.append('[Error while saving image: %s]' % e)
|
builder.append('[Error while saving image: %s]' % e)
|
||||||
else:
|
else:
|
||||||
builder.append('[file stored as %s]' % filename)
|
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:
|
else:
|
||||||
builder.append(_trim(attrs['src']))
|
builder.append(_trim(attrs['src']))
|
||||||
if 'alt' in attrs:
|
if 'alt' in attrs:
|
||||||
|
|
Loading…
Reference in a new issue