Eclipse File URL encoding is broken

I have been struggling with one issue raised to SAP Commerce eclipse plugin for a while and could not create test scenario to reproduce the bug #48

Fortunately one of users came up to situation that if file path to eclipse contains whitespace then it is not possible to convert Eclipse URL to File URL, then to URI to finally get a File instance pointing to local file. 

Long story short, whitespace should be encoded to format %20 to be compatible with standard. Currently (2020/2021 A.D.) it is not. I it is left as " "

Bit long, but unfortunately that scenario is quite often seen in plugin development. I was able to find on Eclipse Bugzilla #145096 and there was a struggle what to do with that... Until script has closed that bug. Bummer.

Last reply was:

Wrong. Non-encoded URLs are lossy. See explanations in bug 3109 comment 28. The only right solution is to stop using non-encoded URLs, even if that breaks buggy API clients that tried to "encode" wrong URLs (that "encoding" is not a well-defined process and hence cannot be supported). Code that tries to use org.eclipse.core.runtime.URIUtil#toURI(URL) is suspicious and shows that the author either didn't know how URLs work, or was forced to cope with broken APIs.
Where I fully agree with author, that working with broken API is a pain and brings a lot of swearing during debugging. Bug from 2016 is still there and no solution proposed.

Fortunately there is a workaround for that:


Comments

Popular posts from this blog

SAP Commerce Cloud and Read-Only Replica

Eclipse plugin development and Apple Silicon M1

FlexibleSearch Pagination