Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Open uri with User and password

Open gabrielrvd opened this issue 3 years ago • 0 comments

Description

Hi, I try open a URL with user and password in Browser.OpenAsync() and the internal method "Browser.EscapeUri" intercept and create a new URI before call native plataform method and remove userinfo from the URI.

Original URI: http://user:[email protected] New URI create by Browser.EscapeUri: http://www.example.com

Why method EscapeUri exists? Is possible remove him?

If is not possible remove EscapeUri, create a new method that not call him.

Steps to Reproduce

  1. Open URI with user and password with Browser.OpenAsync(...)
  2. Browser prompt again for user and password

Expected Behavior

Not change URI

Actual Behavior

Remove user and password from new generated URI

Basic Information

  • Version with issue: All
  • IDE: VS2022
  • Platform Target Frameworks: All plataforms

Workaround

For now I call same internal method that Browser.OpenAsync run by reflection

var type = typeof(Xamarin.Essentials.Browser);
var method = type.GetMethod(
                 "PlatformOpenAsync",
                 BindingFlags.NonPublic
                 | BindingFlags.Public
                 | BindingFlags.Static
                 | BindingFlags.FlattenHierarchy)
             ?? throw new NotImplementedException(
                 "Método 'PlatformOpenAsync' não encontrado para a plataforma");

var task = (Task<bool>)method.Invoke(null, new[] { (object)uri, options });
await task;

gabrielrvd avatar Dec 23 '22 18:12 gabrielrvd