-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Uri] Absolute paths using UriKind.RelativeOrAbsolute parsed as relative on iOS and Android #69618
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Found this reference regarding the difference: https://www.mono-project.com/docs/faq/known-issues/urikind-relativeorabsolute/ |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescription
Reproduction StepsRun the code on both .NET 6 ios/android and legacy xamarin. Note that the asserts are very different for the code to work on both platforms. #if __IOS__ || __ANDROID__
if (System.Uri.TryCreate("/data/user/0/file.txt", System.UriKind.RelativeOrAbsolute, out System.Uri? result))
{
#if NETCOREAPP
System.Diagnostics.Debug.Assert(result.IsAbsoluteUri == false);
try
{
System.Diagnostics.Debug.Assert(result.IsFile == false); //Throws invalid operation
System.Diagnostics.Debug.Assert(false); // We don't get here
}
catch(System.InvalidOperationException)
{
}
#else // Legacy xamarin
System.Diagnostics.Debug.Assert(result.IsAbsoluteUri == true);
System.Diagnostics.Debug.Assert(result.IsFile == true);
#endif
}
#endif Expected behaviorIsAbsoluteUri and IsFile behavior matches legacy xamarin behavior. Actual behaviorIncorrectly doesn't detect that the URL is absolute (ie starting with '/'). Regression?Yes this worked correctly in Xamarin. Known WorkaroundsNo response Configuration.NET 6.0.5, ARM64. iOS and Android. Other informationNo response
|
This was always a difference between .NET [Core] and Mono. The problem is that the input is ambiguous, it can either be relative to server Uri (eg. |
As Filip mentioned, We're solving the opposite problem by introducing a new API in .NET 7 (if we get around to implementing it) that will let you explicitly opt out of parsing implicit file paths (#59099), but there's no plan to make Unix absolute path parsing work on other platforms. If at all possible, I would recommend using |
Triage: Given that this is difference between Mono and .NET Core, there is not much we can do -- having unified ways across our platforms is somewhat useful. |
Description
Uri.TryCreate
withUriKind.RelativeOrAbsolute
fails to detect absolute paths on .NET 6 iOS and Android, whereas this worked with the legacy Xamarin mono runtimes.Reproduction Steps
Run the code on both .NET 6 ios/android and legacy xamarin. Note that the asserts are very different for the code to work on both platforms.
Expected behavior
IsAbsoluteUri and IsFile behavior matches legacy xamarin behavior.
Actual behavior
Incorrectly doesn't detect that the URL is absolute (ie starting with '/').
Regression?
Yes this worked correctly in Xamarin.
Known Workarounds
No response
Configuration
.NET 6.0.5, ARM64. iOS and Android.
Other information
No response
The text was updated successfully, but these errors were encountered: