Windows: '/' in relative image links rewritten as '\' on save

Bug #1659347 reported by su_v on 2017-01-25
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Medium
jazzynico
0.92.x
Medium
jazzynico

Bug Description

Inkscape on Windows rewrites the path separator '/' in relative image links (xlink:href attribute) to '\' on save.

Steps to reproduce:
1) prepare files:
   copy a bitmap image to current folder
   create a sub-folder
   save a new Inkscape SVG drawing into the sub-folder
2) open the just saved drawing in Inkscape
3) import the bitmap image saved in the parent folder
   (link the bitmap image, not embed)
4) with bitmap image selected, open 'Image Properties' from the context menu
5) change the absolute path into a relative path reference:
   ../my_image.png
6) save the drawing

Expected result:
The relative link is saved as entered (and as supported on load even by Windows builds, as tested by externally changing the absolute path into a relative link).

Actual result:
On save, the path separator is changed to '\' (the 'xlink:href' attribute value is changed from '../my_image.png' to '..\my_image.png'). This can be monitored live in the image properties dialog if the image is still selected while saving the modified file (Ctrl+S).

Note:
Issue was first reported by deevad on #inkscape-devel - this can pose issues when collaborating with users across different platforms (e.g. translators for the pepper&carrot comics), because of the unexpected changes to the xlink:href attribute values with Windows builds.

Reproduced with Inkscape 0.92.0 r15299 (64bit, MSI), 0.92.1pre0 r15340 (64bit, 7z) on Windows 10.

Related branches

su_v (suv-lp) on 2017-01-25
description: updated
Alvin Penner (apenner) wrote :

confirmed on Windows 10, Inkscape 0.92.0 r15299

if I load a jpg file using a link, then the XML editor initially reports the link as:
xlink:href = file:///C:/Windows/Temp/cathedral.jpg

after saving the file, the link is shown as:
sodipodi:absref="C:\Windows\Temp\cathedral.jpg"
xlink:href="cathedral.jpg"

Changed in inkscape:
status: New → Confirmed
su_v (suv-lp) wrote :

Please note that the core of the report focuses on the value in the xlink:href attribute. The sodipodi:absref attribute in the custom namespace in my understanding mostly matters on the local platform of the author (absolute links to files on a local hard drive rarely work on other systems). A relative image link in the xlink:href attribute on the other hand is not only used by Inkscape (not restricted to a private namespace used by Inkscape), and AFAIU should not use a OS-specific path separator.

description: updated
jazzynico (jazzynico) wrote :

Also reproduced on Windows XP (32-bit), lp:inkscape/0.92.x rev. 15346.

Changed in inkscape:
importance: Undecided → Medium
status: Confirmed → Triaged
jazzynico (jazzynico) wrote :
Changed in inkscape:
assignee: nobody → jazzynico (jazzynico)
milestone: none → 0.93
status: Triaged → In Progress
jazzynico (jazzynico) wrote :

Patch attached, please test.

I'm afraid it's a bit too late for 0.92.1, so I'm targeting it to 0.92.2 for now.

Bryce Harrington (bryce) wrote :

+1 Approved for landing on 0.92.x branch for inclusion in 0.92.1.

I would like to see testing of this to ensure the issue is fully resolved, but the fix looks straightforward enough.

Remember to land the change with a commit message that explains the user-visible issue, and ref this bug #.

jazzynico (jazzynico) wrote :

> I would like to see testing of this to ensure the issue is fully resolved.

It was fully tested on Windows XP (32-bit), with the 0.92.x branch (rev. 15346).

Eduard Braun (eduard-braun2) wrote :

Seems to work fine on Windows 10, Inkscape 0.92.1pre0 15346 (64-bit)

There are two minor glitches (but I doubt they're caused by this change?):
1. Assume an image file "E:\test\raster.png"
2. Open a new document, embed raster.png and save to "E:\test\drawing.svg". Although the file is in the same directory the full path is saved 'xlink:href="file:///E:/test/raster.png"'. One can avoid this by saving the file once before embedding raster.png
3. Immediately after saving to "E:\test\drawing.svg" in 2. save the file again to ""E:\drawing.svg". You will now end up with 'sodipodi:absref="E:\test/raster.png"' in the saved file.

@jazzynico: You had a look at the relevant code lately. Maybe you can check it out? I guess at least 2 is worth figuring out (for future versions) while most likely not a regression. 3. is obviously only a minor thing.

jazzynico (jazzynico) wrote :

Thanks for your test Eduard.
If I remember correctly, the path in 2 is automatically fixed when saving the file a second time (to be confirmed). I'm going to grab the remaining issues (some where reported in Bug #170225 'relative image paths instead of absolute' - which was never fixed in a released version due to the regression introduced rev.10199).

jazzynico (jazzynico) wrote :

Fixed in lp:inkscape rev. 15459.

Changed in inkscape:
status: In Progress → Fix Committed
jazzynico (jazzynico) wrote :

Fixed in lp:inkscape/0.92.x rev. 15347.

jazzynico (jazzynico) wrote :

@Eduard, just tested again issue #2. The file is correctly saved (checked the SVG directly with a text editor), and thus it's just that the path is not correctly refreshed in the application.

jazzynico (jazzynico) wrote :

Issue #2 again: the SVG file is correct, so there's no need to save twice (you can just reload), but the xlink is still invalid in the Object attribute dialog and in the XML editor.

jazzynico (jazzynico) wrote :

Regarding comment #9, all related bugs from Bug #170225 seem to be fixed in 0.92.

Eduard Braun (eduard-braun2) wrote :

I definitely saw #2 in the saved SVG file (not the XML editor). Are you sure you did not save twice?

jazzynico (jazzynico) wrote :

Yes, I checked on a Windows 8 computer, and checked again on Xubuntu to be sure. To be sure, try to save once and revert, and you should have the expected values.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers