Bug 290667 - URIUtil.fromString(String) incorrectly handle with the '#' character in URI path
Summary: URIUtil.fromString(String) incorrectly handle with the '#' character in URI path
Status: CLOSED WONTFIX
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: Components (show other bugs)
Version: unspecified   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: equinox.components-inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2009-09-28 00:38 EDT by Meng Xin Zhu CLA
Modified: 2021-05-28 08:59 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Meng Xin Zhu CLA 2009-09-28 00:38:36 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729) QQDownload/1.7
Build Identifier: 20090619-0625

Assuming calling p2 API as below,

File f = new File("c:\\path#\\abc");
pass the install URL via f.toURI().toURL(),
then call engine to install IUs.
Mapper decode the URL string, then create URI object from string.
The characters behind '#' are incorrectly handled with fragment.

Thread [Thread-30] (Suspended (breakpoint at line 125 in URIUtil))	
	URIUtil.fromString(String) line: 125	
	Mapper.doReplacement(String, String, String, String, String, String) line: 116	
	Mapper.map(URI, String, String, String, String) line: 74	
	SimpleArtifactRepository.createLocation(ArtifactDescriptor) line: 389	
	SimpleArtifactRepository.getOutputStream(IArtifactDescriptor) line: 704	
	MirrorRequest.transferSingle(IArtifactDescriptor, IArtifactDescriptor, IProgressMonitor) line: 167	
	MirrorRequest.transfer(IArtifactDescriptor, IArtifactDescriptor, IProgressMonitor) line: 159	
	MirrorRequest.perform(IProgressMonitor) line: 95	
	SimpleArtifactRepository.getArtifact(ArtifactRequest, IProgressMonitor) line: 511	
	SimpleArtifactRepository.getArtifacts(IArtifactRequest[], IProgressMonitor) line: 567	
	DownloadManager.fetch(IArtifactRepositoryManager, URI[], SubMonitor) line: 109	
	DownloadManager.start(IProgressMonitor) line: 97	
	Collect.completePhase(IProgressMonitor, IProfile, Map) line: 73	
	Collect(Phase).postPerform(MultiStatus, IProfile, ProvisioningContext, IProgressMonitor) line: 195	
	Collect(Phase).perform(MultiStatus, EngineSession, IProfile, Operand[], ProvisioningContext, IProgressMonitor) line: 78	
	InstallerThread$WRPhaseSet(PhaseSet).perform(ActionManager, EngineSession, IProfile, Operand[], ProvisioningContext, IProgressMonitor) line: 44	
	Engine.perform(IProfile, PhaseSet, Operand[], ProvisioningContext, IProgressMonitor) line: 54	
	InstallerThread.run() line: 152	


Reproducible: Always

Steps to Reproduce:
1. run p2 installer
2. install location contains '#' characters
3. much content of repository are missed after installation
Comment 1 DJ Houghton CLA 2009-09-28 07:42:21 EDT
This is a known issue and is in the README file shipped with Eclipse.

*** This bug has been marked as a duplicate of bug 3109 ***
Comment 2 Meng Xin Zhu CLA 2009-09-28 22:20:13 EDT
They're definitely different problems.
3109 reported the java application can't be launch while the path of application contains !%#.
This one reports p2 installer can't install IUs into the location that contains !%#. 
First of all, the path of p2 installer doesn't contain !%#, and p2 installer can be successfully started.
I admit that the install location with !%# is meaningless for java application. However there is a another scenario, the installed IUs only consist of binary and native library. The application can be launched without such limitation. But p2 installer incorrectly handle with the install location with pound characters, many IUs can't be properly installed.
Comment 4 Mark Rösler CLA 2019-06-07 10:18:33 EDT
I think the problem is that the string given to URIUtil.fromString(String) is not correctly encoded.

file:/C:/path%23/abc is correct encoded and should work
http://path%23/index.html#heading is also correct and would become http://path%23/index.html

but because of Mapper.map(URI, String, String, String, String) call of 
String locationString = URIUtil.toUnencodedString(repositoryLocation);
the %23 is replaced with # and given to URIUtil.fromString(String)

so file:/C:/path%23/abc becomes file:/C:/path#/abc and URIUtil.fromString(String) removes the last part and it becomes file:/C:/path
Comment 5 Eclipse Genie CLA 2021-05-28 08:59:32 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.