Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316650 - PathUtil doesn't make paths relative correctly across volumes
Summary: PathUtil doesn't make paths relative correctly across volumes
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6.1   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-11 15:57 EDT by John Arthorne CLA
Modified: 2010-06-23 16:03 EDT (History)
4 users (show)

See Also:


Attachments
Fix and regression test v01 (6.50 KB, patch)
2010-06-11 15:59 EDT, John Arthorne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2010-06-11 15:57:35 EDT
Build: 3.6

PathUtil.makeRelative("file:/a/b", new URL("file:/d:/a/x))

Returns: "file:../b", but since the device is different it should return "file:/c:/a/b".
Comment 1 John Arthorne CLA 2010-06-11 15:59:35 EDT
Created attachment 171764 [details]
Fix and regression test v01
Comment 2 John Arthorne CLA 2010-06-11 16:02:27 EDT
I noticed while testing this that PathUtil has all kinds of crazy behaviour. It can return a mixture of / and \ path separators on Windows. It also creates bad relative URLs such as file:a/b/ (relative URL shouldn't have a device). In any case I've opted not to change anything else in this patch except the cross-volume bug. This class is generally only used in backwards compatibility situations like reading/writing plaform.xml, and most of p2 uses the much more consistent URIUtil methods.
Comment 3 John Arthorne CLA 2010-06-11 16:30:24 EDT
Sorry, that first line should read:

PathUtil.makeRelative("file:/c:/a/b", new URL("file:/d:/a/x))

Returns: "file:../b" but should return "file:/c:/a/b".
Comment 4 John Arthorne CLA 2010-06-22 10:47:32 EDT
Fix released for 3.6.1 and 3.7
Comment 5 John Arthorne CLA 2010-06-23 16:03:58 EDT
*** Bug 311387 has been marked as a duplicate of this bug. ***