Commit d4876cd3 authored by Tristan Cavelier's avatar Tristan Cavelier

erp5_web: mhtml: fix "?display=" image conversion

/reviewed-on !210
parent 4d1e667c
...@@ -169,6 +169,7 @@ def handleImageSourceObject(obj, src): ...@@ -169,6 +169,7 @@ def handleImageSourceObject(obj, src):
if key == "format" and value is not None: if key == "format" and value is not None:
format_kw["format"] = value format_kw["format"] = value
elif key == "display" and value is not None: elif key == "display" and value is not None:
format_kw.setdefault("format", "")
format_kw["display"] = value format_kw["display"] = value
if format_kw: if format_kw:
mime, data = obj.convert(**format_kw) mime, data = obj.convert(**format_kw)
......
...@@ -1371,6 +1371,7 @@ return True ...@@ -1371,6 +1371,7 @@ return True
page.edit(text_content="".join([ page.edit(text_content="".join([
"<p>Hello</p>", "<p>Hello</p>",
'<img src="%s?format=" />' % svg.getRelativeUrl(), '<img src="%s?format=" />' % svg.getRelativeUrl(),
'<img src="%s?display=" />' % svg.getRelativeUrl(),
'<img src="/%s?format=" />' % svg.getRelativeUrl(), '<img src="/%s?format=" />' % svg.getRelativeUrl(),
'<img src="//test.portal.erp/%s?format=" />' % svg.getRelativeUrl(), '<img src="//test.portal.erp/%s?format=" />' % svg.getRelativeUrl(),
'<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(), '<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(),
...@@ -1389,7 +1390,7 @@ return True ...@@ -1389,7 +1390,7 @@ return True
"<p>Hello</p>", "<p>Hello</p>",
] + ([ ] + ([
'<img src="data:image/svg+xml;base64,%s" />' % b64encode(XSMALL_SVG_IMAGE_ICON_DATA), '<img src="data:image/svg+xml;base64,%s" />' % b64encode(XSMALL_SVG_IMAGE_ICON_DATA),
] * 5) + [ ] * 6) + [
'<img src="%s//example.com/%s?format=" />' % (protocol, svg.getRelativeUrl()), '<img src="%s//example.com/%s?format=" />' % (protocol, svg.getRelativeUrl()),
'<img src="http://example.com/%s?format=" />' % svg.getRelativeUrl(), '<img src="http://example.com/%s?format=" />' % svg.getRelativeUrl(),
'<img src="https://example.com/%s?format=" />' % svg.getRelativeUrl(), '<img src="https://example.com/%s?format=" />' % svg.getRelativeUrl(),
...@@ -1412,6 +1413,7 @@ return True ...@@ -1412,6 +1413,7 @@ return True
page.edit(text_content="".join([ page.edit(text_content="".join([
"<p>Hello</p>", "<p>Hello</p>",
'<img src="%s?format=" />' % svg.getRelativeUrl(), '<img src="%s?format=" />' % svg.getRelativeUrl(),
'<img src="%s?display=" />' % svg.getRelativeUrl(),
'<img src="/%s?format=" />' % svg.getRelativeUrl(), '<img src="/%s?format=" />' % svg.getRelativeUrl(),
'<img src="//test.portal.erp/%s?format=" />' % svg.getRelativeUrl(), '<img src="//test.portal.erp/%s?format=" />' % svg.getRelativeUrl(),
'<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(), '<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(),
...@@ -1434,6 +1436,7 @@ return True ...@@ -1434,6 +1436,7 @@ return True
"".join([ "".join([
"<p>Hello</p>", "<p>Hello</p>",
'<img src="%s/%s?format=" />' % (page.absolute_url(), svg.getRelativeUrl()), '<img src="%s/%s?format=" />' % (page.absolute_url(), svg.getRelativeUrl()),
'<img src="%s/%s?display=" />' % (page.absolute_url(), svg.getRelativeUrl()),
'<img src="%s?format=" />' % svg.absolute_url(), '<img src="%s?format=" />' % svg.absolute_url(),
'<img src="%s//test.portal.erp/%s?format=" />' % (protocol, svg.getRelativeUrl()), '<img src="%s//test.portal.erp/%s?format=" />' % (protocol, svg.getRelativeUrl()),
'<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(), '<img src="http://test.portal.erp/%s?format=" />' % svg.getRelativeUrl(),
...@@ -1448,10 +1451,11 @@ return True ...@@ -1448,10 +1451,11 @@ return True
) )
for message, location in [ for message, location in [
(message.get_payload()[1], "%s/%s?format=" % (page.absolute_url(), svg.getRelativeUrl())), (message.get_payload()[1], "%s/%s?format=" % (page.absolute_url(), svg.getRelativeUrl())),
(message.get_payload()[2], "%s?format=" % svg.absolute_url()), (message.get_payload()[2], "%s/%s?display=" % (page.absolute_url(), svg.getRelativeUrl())),
(message.get_payload()[3], "%s//test.portal.erp/%s?format=" % (protocol, svg.getRelativeUrl())), (message.get_payload()[3], "%s?format=" % svg.absolute_url()),
(message.get_payload()[4], "http://test.portal.erp/%s?format=" % svg.getRelativeUrl()), (message.get_payload()[4], "%s//test.portal.erp/%s?format=" % (protocol, svg.getRelativeUrl())),
(message.get_payload()[5], "https://test.portal.erp/%s?format=" % svg.getRelativeUrl()), (message.get_payload()[5], "http://test.portal.erp/%s?format=" % svg.getRelativeUrl()),
(message.get_payload()[6], "https://test.portal.erp/%s?format=" % svg.getRelativeUrl()),
]: ]:
self.assertEqual( self.assertEqual(
message.get("Content-Location"), message.get("Content-Location"),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment