Bug 61096 - FILESAVE: XHTML export of doc with image broken
Summary: FILESAVE: XHTML export of doc with image broken
Status: RESOLVED DUPLICATE of bug 113696
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.0.0.3 release
Hardware: All All
: medium major
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: (X)HTML-Export
  Show dependency treegraph
 
Reported: 2013-02-19 03:19 UTC by clkao
Modified: 2021-05-19 09:32 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
sample doc containing image (2.47 MB, application/msword)
2013-02-19 03:19 UTC, clkao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description clkao 2013-02-19 03:19:52 UTC
Created attachment 75085 [details]
sample doc containing image

1. open the attached doc
2. file -> export -> xhtml
3. open the resulting xhtml in browser, you'll see the broken image

The image in the resulting xhtml is using inline base64, however if I manually replace  src="data:image/*;base64,<BASE64>" with the output of `base64 file.gif` the image in the xhtml works fine.

"Save as html" stores the image externally and works fine.  (I use the image saved by the html saver to run base64 with)
Comment 1 Thomas van der Meulen [retired] 2013-02-19 08:11:52 UTC
Thank you for reporthing this bug,
I can reporduce this bug running LibreOffice 4.0.0.3 on Windows 7.

I have tryed i out with a other .wmf file and it also was broken. 
I think it is because of the .wmf files.
Comment 2 QA Administrators 2015-04-19 03:23:25 UTC Comment hidden (obsolete)
Comment 3 lyforever62 2015-06-02 16:02:55 UTC
Bug still exists.

LibreOffice 4.4.3.2
OS: Mac OSX 10.10.3
Comment 4 QA Administrators 2016-09-20 09:46:18 UTC Comment hidden (obsolete)
Comment 5 Greg Ross 2017-02-25 00:22:39 UTC
Confirmed the bug still exists.

LibreOffice 5.3.0.3
OS: Windows 10 (x64)

Some additional notes:

- Broken in IE and Edge, but not Firefox or Vivaldi.
- Looks to be a problem with the "src="data:image/*;base64" header as if you replace it with "src="data:image/png;base64" all works correctly.
Comment 6 Greg Ross 2017-02-25 03:08:57 UTC
I did some digging, this appears to be an issue in "filter/source/xslt/odf2xhtml/export/common/body.xsl", see line 335:

<xsl:text>data:image/*;base64,</xsl:text><xsl:value-of select="office:binary-data"/>

When the ODF is converted to XHTML it sets *all* image files to the "image:/*" media type instead of specifying what kind of image it is.

A wildcard subtype is not a supported mime type and is therefore completely dependent on the browser being used.

Instead I think line 335 should be replace with (may contain errors, first attempt at writing XSLT):

<xsl:choose>
	<xsl:when test="contains(upper-case($filename), '.JPG') or contains(upper-case($filename), '.JPEG')">
		<xsl:text>data:image/jpg;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:when>
	<xsl:when test="contains(upper-case($filename), '.SVG')">
		<xsl:text>data:image/svg;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:when>
	<xsl:otherwise>
		<xsl:text>data:image/png;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:otherwise>
</xsl:choose>
Comment 7 Greg Ross 2017-02-25 03:49:09 UTC
Two updates to the above code, use correct variable for the href name and use ends-with() to ensure not to catches files like "name.jpeg.txt":

<xsl:choose>
	<xsl:when test="ends-with(upper-case($href), '.JPG') or ends-with(upper-case($href), '.JPEG')">
		<xsl:text>data:image/jpg;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:when>
	<xsl:when test="ends-with(upper-case($href), '.SVG')">
		<xsl:text>data:image/svg;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:when>
	<xsl:otherwise>
		<xsl:text>data:image/png;base64,</xsl:text><xsl:value-of select="office:binary-data"/>
	</xsl:otherwise>
</xsl:choose>
Comment 8 Jacques Guilleron 2017-06-07 15:06:13 UTC
Hi all,

Image stil missing when tried with 
LO 5.5.0.0.alpha0+ Build ID: 0e6297932252403883a6057feee488e4ee2bc360
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@39, Branch:master, Time: 2017-05-23_00:14:17
Locale: fr-FR (fr_FR); Calc: CL

Jacques
Comment 9 Julien Nabet 2017-06-15 21:09:22 UTC
(In reply to Greg Ross from comment #7)
> Two updates to the above code, use correct variable for the href name and
> use ends-with() to ensure not to catches files like "name.jpeg.txt":
> 
> <xsl:choose>
> 	<xsl:when test="ends-with(upper-case($href), '.JPG') or
> ends-with(upper-case($href), '.JPEG')">
> 		<xsl:text>data:image/jpg;base64,</xsl:text><xsl:value-of
> select="office:binary-data"/>
> 	</xsl:when>
> 	<xsl:when test="ends-with(upper-case($href), '.SVG')">
> 		<xsl:text>data:image/svg;base64,</xsl:text><xsl:value-of
> select="office:binary-data"/>
> 	</xsl:when>
> 	<xsl:otherwise>
> 		<xsl:text>data:image/png;base64,</xsl:text><xsl:value-of
> select="office:binary-data"/>
> 	</xsl:otherwise>
> </xsl:choose>

I tried to directly replace image/* by image/jpg, image/png, image/bmp and image/svg directly on resulting file, it still doesn't image.
I converted doc file in odt then unzipped it and found a wmf file.
Comment 10 QA Administrators 2018-06-27 02:48:13 UTC Comment hidden (obsolete)
Comment 11 QA Administrators 2020-06-27 03:49:15 UTC Comment hidden (obsolete)
Comment 12 Stéphane Guillou (stragu) 2021-05-18 06:48:29 UTC
It's a "works for me" in current 7.2 Alpha. The export uses "src="data:image/png;base64" and the image shows in Firefox 88.0.1

Also works on LO 7.0.4.2 and 7.1.3.2, so must have been fixed for a while.

Tested with:

Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 6b09276d157abada74e1a4989700139167207778
CPU threads: 8; OS: Linux 4.15; UI render: default; VCL: gtk3
Locale: en-AU (en_AU.UTF-8); UI: en-US
TinderBox: Linux-rpm_deb-x86_64@86-TDF, Branch:master, Time: 2021-05-14_04:32:30
Calc: threaded
Comment 13 Xisco Faulí 2021-05-19 09:32:32 UTC
Issue fixed by https://cgit.freedesktop.org/libreoffice/core/commit/?id=a0647dfdbbea483ed3a8372b7a54e1934dfa1fe5, which fixes 113696
Closing as duplicated

*** This bug has been marked as a duplicate of bug 113696 ***