mirror of
https://github.com/bitwarden/mobile.git
synced 2025-01-22 21:11:27 +01:00
Fixes to uri parsing (#860)
This commit is contained in:
parent
1d48171fd5
commit
69e0906491
@ -147,7 +147,7 @@ namespace Bit.Droid.Accessibility
|
||||
return uri;
|
||||
}
|
||||
|
||||
public static string ExtractUri(string uri, AccessibilityNodeInfo addressNode, Browser browser)
|
||||
private static string ExtractUri(string uri, AccessibilityNodeInfo addressNode, Browser browser)
|
||||
{
|
||||
if (addressNode?.Text == null)
|
||||
{
|
||||
@ -160,21 +160,13 @@ namespace Bit.Droid.Accessibility
|
||||
uri = browser.GetUriFunction(addressNode.Text)?.Trim();
|
||||
if (uri != null && uri.Contains("."))
|
||||
{
|
||||
if (!uri.Contains("://") && !uri.Contains(" "))
|
||||
if (Uri.TryCreate(uri, UriKind.Absolute, out var uri2))
|
||||
{
|
||||
uri = string.Concat("http://", uri);
|
||||
return uri;
|
||||
}
|
||||
else if (Build.VERSION.SdkInt <= BuildVersionCodes.KitkatWatch)
|
||||
if (Uri.TryCreate("http://" + uri, UriKind.Absolute, out var uri3))
|
||||
{
|
||||
var parts = uri.Split(new string[] { ". " }, StringSplitOptions.None);
|
||||
if (parts.Length > 1)
|
||||
{
|
||||
var urlPart = parts.FirstOrDefault(p => p.StartsWith("http"));
|
||||
if (urlPart != null)
|
||||
{
|
||||
uri = urlPart.Trim();
|
||||
}
|
||||
}
|
||||
return string.Concat("http://", uri);
|
||||
}
|
||||
}
|
||||
return uri;
|
||||
|
@ -85,15 +85,14 @@ namespace Bit.Core.Utilities
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var httpUrl = uriString.StartsWith("https://") || uriString.StartsWith("http://");
|
||||
if (!httpUrl && !uriString.Contains("://") && Regex.IsMatch(uriString, TldEndingRegex))
|
||||
{
|
||||
uriString = "http://" + uriString;
|
||||
}
|
||||
if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
|
||||
{
|
||||
return uri;
|
||||
}
|
||||
if (Uri.TryCreate("http://" + uriString, UriKind.Absolute, out var uri2))
|
||||
{
|
||||
return uri2;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user