Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 289544

Summary: Bundles with %2C
Product: [Eclipse Project] Equinox Reporter: bungeman
Component: FrameworkAssignee: equinox.framework-inbox <equinox.framework-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: pascal, tjwatson, vsoldatov
Version: unspecified   
Target Milestone: 3.6 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The unit test for catch the bug with space in budne path none

Description bungeman CLA 2009-09-15 23:49:29 EDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.13) Gecko/2009080315 Ubuntu/9.04 (jaunty) Firefox/3.0.13
Build Identifier: M20090211-1700

This is related to the fix for Bug 256332 .

At this time,

org.eclipse.equinox/p2/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorUtils.java #createBundleLocation(URI, boolean)

encodes a ',' in a location as '%2C' and

org.eclipse.equinox/p2/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java #parseLocation(String)

decodes it. Unfortunately, it is quite allowed on Linux to name a file '%2C' or simply have '%2C' in it at an arbitrary location. As a result, it is not enough to simply escape ',' as '%2C'. The only clean thing to do is to properly escape '%' in the location as '%25'. Otherwise bundles with '%2C' in the URI will have ',' incorrectly substituted when deserialized.

It seems that the easiest fix for this would simply be to encode the '%' to '%25' first, then encode ',' to '%2C'. Decoding would then do the opposite, decode '%2C' to ',' first, then decode '%25' to '%'. Of course, other methods are possible.

Reproducible: Always

Steps to Reproduce:
1. Create a plugin jar with '%2C' in the filename (or otherwise put the
plugin in a path with '%2C' in it).
2. Get the plugin into the bundles.info file somehow (dropins, p2, link).
3. Profit!!!
4. Bad things(TM) willl happen because the '%2C' got turned into ',' so the wrong file will be set for the bundle.
Comment 1 Pascal Rapicault CLA 2009-09-16 21:50:09 EDT
See also bug #289644.
Comment 2 Vyacheslav Soldatov CLA 2010-01-08 16:17:37 EST
Seems like it is a bug of org.eclipse.osgi.internal.baseadaptor.BundleInstall.
The code from line 73:
File inFile = new File(source.getURL().getPath());
if (inFile.isDirectory())
    AdaptorUtil.copyDir(inFile, outFile);
else
    AdaptorUtil.readFile(in, outFile);

source.getURL() contains URL encoded file name. The file name should be decoded back before creating of java.io.File instance.

BR, Vyacheslav
Comment 3 Andrew Niefer CLA 2010-04-08 17:16:27 EDT
I'm not seeing problems here, on linux I dropped in a bundle named "aniefer,junit%25Cheadless_1.0.0.200911060948.jar".  

This was correctly installed into the bundle.info as "dropins/aniefer%2Cjunit%252Cheadless_1.0.0.200911060948.jar"
The bundle is resolved and working in the running eclipse.

The unit test I wrote for SimpleConfiguratorManipulator saveConfiguration & loadConfiguration is properly handling "plu%2cins" and "plu,ins".
Comment 4 Vyacheslav Soldatov CLA 2010-04-09 09:41:46 EDT
Hi Andrew

This is not a problem of loading bundle from jar file. This is a problem of loading bundle from the folder. I understand that in OSGI specification the bundle should be a jar file, but Equinox framework supports the loading bundle from the folder as additional feature. I think it should work fine. Ok, i going to prepare the unit test for demonstrate the bug, and will sent it today.

Thank You, Vyacheslav
Comment 5 Vyacheslav Soldatov CLA 2010-04-09 10:47:44 EDT
Created attachment 164381 [details]
The unit test for catch the bug with space in budne path

The unit test is attached. Once i also not get the problem with ',' symbol in the path, but i've the problem with ' ' space symbol in path.

BR, Vyacheslav
Comment 6 Andrew Niefer CLA 2010-04-12 16:55:56 EDT
SimpleConfigurator works fine for me here, sending over to the framework for comment on installing bundles with an encoded location.

Note that the simple configurator unencodes the location before calling install.
Comment 7 Thomas Watson CLA 2010-04-12 17:07:39 EDT
Please try on the latest build.  bug290193 was fixed in 3.6 M3.

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