-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
missing check for file:/// on making a new File #1260
Comments
I am not so sure about this to be honest. There is quite a bit of history around this functionality, at the moment I can't recall all of the details unfortunately, and it's been like this a long time. I'll look into it. |
doing some look into it adding (another) basic check also fixes it too. |
if you pass "A:\whatever" then it isn't a URL, it's a local file. |
There was already an issue I opened in the vlcj project itself to determine if this code was still required at all in fact. I have a nagging doubt about this code, it has been in vlcj for a long time, for some specific reasons. Hopefully there's something in the commit log about this file which will prompt me to remember. |
Indeed, but local files in a Anyway, seeing MRL doesn't longer need a special encoding. The best option is change the MRL type from String to for file protocol is enough do |
OK, but really if you do have a local file, you're not supposed to pass it as a URL. LibVLC has two dedicated native functions for loading a local file vs an "MRL". An MRL is like a URL but I'm not sure it's 100% interchangeable. It's not Java's URL class that's doing the work here, it has to be serialised a string, and passed to the native function as that string. This is why I'm a bit wary of this problem, as it comes down to how VLC handles MRLs. |
passing the file path as an URL works fine |
Regardless my suggestion of switch encodeUri and convert from a string to
Yes, neither URI or File are doing nothing except "validate if is a path or a url". |
Could you please maybe summarise the current difficulty here, i.e. the current state of this issue/request from your point of view? For wider context, I am struggling to remember the full history of why this code is in vlcj since it has likely been here for over 10 years in some form or another. I think part of it is to do with handling UNICODE character conversions, which was a particular problem with vlcj on older versions of Java, and maybe VLC too. |
I was a little disconnected so i lost the track of what was happening inside. i have to re-study all the code SummaryMy issue is based on the process to parse a file URL. Also VLC rejects that Uri syntax/protocol ( What i did is convert the mrl string to always have the This was caused by this code: that code basically wraps the URL as a file, and because is not a normalized path string it gets attached into process dir, making the path looks like ASSUMPTIONS (nothing checked)I honestly removed any ASCII encoding and it still works, accepts few odd urls with unicode characters. Thats because in the old days ASCII was the standard, considering how often was required tell to gradle, java and few text editors to manually use UTF-8. I assume VLC 2 was using ASCII as default but got changed on VLC 3(? In any case i was working with that on watermedia for a long time and there wasn't reported issues about URL's getting failed to load by VLC due to bad MRL sources IMPORTANT SPOTS
My suggestionsOne of the fixes i did on the silly fork i made was use ExtraURI also forces dev to encode the URL to mitigate "non-valid" chars VLC supports both types of file MRL, as URL or as a File path, URL Encoded or not |
This issue is still being considered. |
When the mrl is converted to ASCII. it first converts the uri into a File to then check if starts with
file://
problem starts when you already sends the mrl with the
file://
protocol. Making a new File will ends in a nested path such asfile:///C:\path\of\the\process\C:\path\of\the\process\config\myvideo.mp4
https://github.com/caprica/vlcj-natives/blob/72e800fd461bf63a7ea4aa0008fdfa7f71e14c0d/src/main/java/uk/co/caprica/vlcj/binding/support/strings/NativeUri.java#L120-L129
the fix for that is before convert to file, check if the uri starts with
file:///
(according with the format ofnew URL()
), so it can be safety converted into a file to then convert it into a ASCII stringThe text was updated successfully, but these errors were encountered: