Bug Hunting Session
Bug 79305 - FILESAVE: relative file hyperlinks saved as absolute
Summary: FILESAVE: relative file hyperlinks saved as absolute
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha1
Hardware: Other All
: high major
Assignee: Markus Mohrhard
URL:
Whiteboard: target:4.4.0 target:4.3.1 target:4.2....
Keywords: bibisected, regression
Depends on:
Blocks: mab4.2
  Show dependency treegraph
 
Reported: 2014-05-27 12:13 UTC by Andras Timar
Modified: 2019-07-08 15:21 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andras Timar 2014-05-27 12:13:16 UTC
1. Launch Calc, make sure that in menu 'Tools -> Options ->   Load/Save -> General - Save - "Save URLs relative to file  system"' is checked.
2. Select Insert - Hyperlink from the menu, and select a file from file picker.
3. Save the document in ODS.

In contents.xml there is a full absolute path instead of a relative path. For example: 

xlink:href="file:///mnt/sda2/Adatok/LO/LO_proba/Melleklet/Dokumentum.pdf"

The same process with LibreOffice 4.1.6 leads to the correct URL:

xlink:href="../Melleklet/Dokumentum.pdf"
Comment 1 Andras Timar 2014-05-27 12:15:06 UTC
First bad commit is in the range of 0404f37297c4b283972d71c8f53765d9169bdafa..d06e5adc21f29c8954021a60445a5c0810731d9e.
Comment 2 Bugcruncher 2014-06-11 14:34:37 UTC
After having damaged dozens of documents within few days I think "NORMAL" is some underestimation. 

An arbitrary edit and save with an old Portable version healed the broken links in a test document (if they are at their original place), but that is unreasonable work.
Comment 3 Edgar Grill 2014-06-17 10:37:11 UTC
Confirmed in LOO 4.2.3 (Windows x86)

---

Another method you could try for healing already corrupted files is to programmatically search and replace the link targets in CONTENT.XML unzipped from the ODS file.
This could be easily achieved massively via GNU sed (invoked by a script which runs over a collection of files) - or by hand with any text editor - because link target are stored in this way:

  <style:hyperlink xlink:href="protocol://target" xlink:type="simple"/>

Where "protocol" stands either for "file" or "http"
So, if we have:

  <style:hyperlink xlink:href="protocol://absolute-path/target-file" xlink:type="simple"/>

We can easily revert it to

  <style:hyperlink xlink:href="protocol://relative-path/target-file" xlink:type="simple"/>

By stripping away the fixed part of absolute path:

  sed -i '' 's/part-of-path-to-strip//' content.xml

in all hyperlinks included in the same spreadsheet. In order to identify the string to strip (or modify...), you can also take a comfortable look to the XML with a web browser.
Comment 4 Edgar Grill 2014-06-17 10:42:07 UTC
>   sed -i '' 's/part-of-path-to-strip//' content.xml

Sorry for the typos... It has to be:

    sed -i '' 's|part-of-path-to-strip||g' content.xml

- "g" at the end for global substitution (whitout this, sed performs only the first substitution)

- Pipes instead of slashes, to allow for slashes in the string to match whitout having to escape them
Comment 5 Commit Notification 2014-07-19 11:41:33 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7c03aacb6746cc136f10acdc6ff8b146db62c8ad

respect flag for relative paths, fdo#79305



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2014-07-19 11:41:45 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=76d66256bb6825069f02e759983ef36df1404976

add test for fdo#79305



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Commit Notification 2014-07-21 15:03:54 UTC
Markus Mohrhard committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=f6445efb0e5c3de099f0425825fe1e6e8271dfb9&h=libreoffice-4-3

respect flag for relative paths, fdo#79305


It will be available in LibreOffice 4.3.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 8 Eike Rathke 2014-07-21 15:31:28 UTC
Note: the change builds a path relative to the ODF package, but instead the IRI should be relative to the package's file stream, which adds another level. Effectively, for a file in the same directory as the document it would be xlink:href='../basename.ext' which LO 4.1.6 wrote.

I guess this needs adaption as readers may expect this defined behavior..
Comment 9 Commit Notification 2014-07-21 16:53:46 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=bc3b62e25eb0c3921fa600e80eeb314e45ecaaef

use SvXMLExport::GetRelativeReference(), fdo#79305



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 10 Eike Rathke 2014-07-21 17:13:01 UTC
Pending review
https://gerrit.libreoffice.org/10444 for 4-3
https://gerrit.libreoffice.org/10445 for 4-2
https://gerrit.libreoffice.org/10446 for 4-2-6
Comment 11 Commit Notification 2014-07-22 14:01:27 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-4-2-6":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c4ad8f54e39d40b58223bcac99510d9798b7cdda&h=libreoffice-4-2-6

use SvXMLExport::GetRelativeReference(), fdo#79305


It will be available already in LibreOffice 4.2.6.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 12 Commit Notification 2014-07-22 14:28:43 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7633ae819b0c29c2c108158d43d4d3f9c4622e7e&h=libreoffice-4-3

use SvXMLExport::GetRelativeReference(), fdo#79305


It will be available in LibreOffice 4.3.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 13 Commit Notification 2014-07-22 14:30:30 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "libreoffice-4-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=23e54b541892c0343e012b51c5722f8e3edc02ef&h=libreoffice-4-2

use SvXMLExport::GetRelativeReference(), fdo#79305


It will be available in LibreOffice 4.2.7.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 14 Robinson Tryon (qubit) 2015-12-17 08:18:24 UTC
Migrating Whiteboard tags to Keywords: (bibisected)
[NinjaEdit]
Comment 15 Commit Notification 2019-07-08 15:21:16 UTC
Eike Rathke committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/7ec598639a900e21ea472a85057aadee10796778%5E%21

Resolves: tdf#126255 correct xlink:href to escape package, tdf#79305 related

It will be available in 6.4.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.