| Summary: | Program#execute(String) broken for file:/ arguments containing # | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Markus Keller <markus.kell.r> | ||||
| Component: | SWT | Assignee: | Lakshmi P Shanmugam <lshanmug> | ||||
| Status: | RESOLVED FIXED | QA Contact: | Silenio Quarti <Silenio_Quarti> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | lshanmug | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7 M7 | ||||||
| Hardware: | PC | ||||||
| OS: | Mac OS X | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
I filed bug 339671 for a similar problem on GTK (there, the fragment is cut away, which is also wrong, but not as bad as the wrong escaping). On Windows 7, the fragment is passed to the browser as expected. Looks like # is a valid character for filename on Mac. In that case I think we should escape # when it is part of the filename and shouldn't escape only when it is used as an anchor. > Looks like # is a valid character for filename on Mac. In that case I think we
> should escape # when it is part of the filename and shouldn't escape only when
> it is used as an anchor.
The difference should be whether the passed argument is a plain path to a file or if it's a file:/ URL.
In file:/ URLs, any special character in the file name should already be escaped in the string you get, so for valid URLs, there's no need to modify any part of the URL.
Created attachment 191088 [details]
patch
Patch adds a check for file:/ Silenio, can you please review the patch? Looks good. One question: Why it is not "file://" instead of "file:/"? (In reply to comment #7) > One question: Why it is not "file://" instead of "file:/"? file:/path seems to be valid and work same as file:///path. The browser (I tried with Safari & Firefox) takes file URL as file:/<path> and changes it to file:///<path>. NSWorkspace.openURLs() too opens this URL. Thanks Silenio. Fixed in HEAD > 20110315 |
I20110310-1119 Cocoa Program#execute(String) is broken for file:/ arguments containing #. When I generate Javadoc and then want to open the Javadoc of a method selected in the editor in the system browser, then # is wrongly escaped before the argument is passed to the browser (resulting in an URL with %23, which is wrong). Example: String urlText = "file:/Users/mk/Documents/runtime-New_configuration/javaP/doc/p/A.html#foo()"; Program program = Program.findProgram("html"); program.execute(urlText); The problems is in org.eclipse.swt.program.Program.getURL(String). If I add || lowercaseName.startsWith ("file:/") to the condition, then it works. And I can still open files with interesting names like "a,b#&c [%23].html".