Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] [Shell] Navigation URL parameter not correctly encoded/decoded #10899

Closed
Jabbah76 opened this issue May 30, 2020 · 1 comment · Fixed by #12186
Closed

[Bug] [Shell] Navigation URL parameter not correctly encoded/decoded #10899

Jabbah76 opened this issue May 30, 2020 · 1 comment · Fixed by #12186
Labels
a/navigation a/shell 🐚 in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Milestone

Comments

@Jabbah76
Copy link

Description

Using Xamarin.Forms Shell navigation a URL is not correctly passed from one viewmodel to another viewmodel. Either the source viewmodel is not correctly encoding the URL, or the destination viewmodel is not correctly decoding it.

The :// part of the URL ends up with :/

For example, when you pass http://www.google.com to the destination viewmodel, the resulting URL becomes http:/www.google.com (with a single slash)

Steps to Reproduce

Using the following code in the source viewmodel:

string url = "http://www.google.com";
await Shell.Current.GoToAsync($"general/showUrl?myUrl={url}");

In the destination viewmodel:

[QueryProperty("MyUrl", "myUrl")]
public class ShowImageViewModel : BaseViewModel
{
    private string _myUrl;

    public string MyUrl
    {
        get => _myUrl;
        set
        {
            _myUrl = Uri.UnescapeDataString(value);
            OnPropertyChanged("MyUrl");
        }
    }
}

Here, _myUrl is http:/www.google.com.

I also tried to escape the URL before passing it, but that doesn't work:

await Shell.Current.GoToAsync($"general/showUrl?myUrl={Uri.EscapeUriString(url)}");

Expected Behavior

Source URL == Destination URL

Actual Behavior

2 slashes end up as 1 slash when passed.

Basic Information

  • Version with issue: 4.6.0.800
  • IDE: Visual Studio MAC
  • Platform Target Frameworks:
    • Android: 9.0

Workaround

In destination ViewModel:

_myUrl = Uri.UnescapeDataString(value).Replace(":/", "://");

@Jabbah76 Jabbah76 added s/unverified New report that has yet to be verified t/bug 🐛 labels May 30, 2020
@jsuarezruiz jsuarezruiz added a/navigation a/shell 🐚 and removed s/unverified New report that has yet to be verified labels Jun 1, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
melihercan added a commit to melihercan/FeedReader that referenced this issue Sep 10, 2020
@PureWeen
Copy link
Contributor

duplicate #9449

@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Sep 22, 2020
rmarinho pushed a commit that referenced this issue Oct 7, 2020
…fixes #10899

* Fix query parsing and allow more types

* Update ShellNavigationState.cs

* Update Xamarin.Forms.Core.UnitTests.csproj
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/navigation a/shell 🐚 in-progress This issue has an associated pull request that may resolve it! t/bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants