-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #4357: spoon doesn't handle paths containinig spaces correctly #4358
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5987064
fix #4357: spoon doesn't handle paths containinig spaces correctly
xzel23 636bdd9
add testcase
xzel23 f6caec6
change the test case to make sure that the model cannot be built with…
xzel23 bb92e4f
change the test case to make sure that the model cannot be built with…
xzel23 f540fbb
recompile with JDK 8 compatibility
xzel23 61e78b7
recompile with JDK 8 compatibility
xzel23 af3b36c
remove source file
xzel23 f00ec5d
move test to LauncherTest
xzel23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import bar.Bar; | ||
|
||
public class Foo { | ||
Foo() { | ||
} | ||
|
||
Bar foo() { | ||
return new Bar(); | ||
} | ||
} |
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is better or something like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am unconvinced. Now that you remind me:
Path.of(URL)
will throw an exception if the URL is not pointing to something that lies on a filesystem or if no FileSystemProvider supporting the URL's protocol is present. For example to create a Path instance that points to a file located inside a Jar file (not the Jar itself), there has to be a FileSystem instance for the Jar file. In the case of the "jar:" protocol, Path.of(URL) will make a disk access and try to read the Jar content and fail if the file is not present or cannot be read. You can try this withjshell
:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt the existing code can handle files inside JARs either? URL-Decoding the
getPath()
would returnfile:/hello.jar!/hello.txt
which likely isn't handled correctly. I'd need to have a look at it, but failing early instead of maybe failing later on sounds like a plus to me?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this assumes utf8 encoding. How does this work on Windows when there's a non-ASCII character in the filepath?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@slarse Maybe someone with access to a windows box could test. In any case, URLs should use UTF-8. Qutoe taken from W3.org:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not fully convinced, that JDT accepts file paths referring to files inside a jar or other weird things correctly, so I am not sure raw URL decoding really is a benefit here over stricter Path.of validation/conversion.
Either way, I tried it out @slarse and the URLDecode javadoc states that it only uses the charset for percent-encoded data.
new URL("öäüß")
is not stored percent encoded, so the string is returned unchanged in the default JVM windows charset. The UTF-8 setting has no relevance for it, but if the URL does contain other percent encoded data it could maybe end up with a String using two encodings.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xzel23 I did not know that, good to know what the spec says (although I doubt all file systems follow that, a filepath is not necessarily a URI). I just don't trust Windows not to be the odd one out on.. everything.
@I-Al-Istannen Thanks for checking it out, that's 100% confusing :D