mirror of
https://github.com/bitwarden/android.git
synced 2024-11-01 07:35:52 +03:00
Fixes to uri parsing (#860)
This commit is contained in:
parent
1d48171fd5
commit
69e0906491
2 changed files with 9 additions and 18 deletions
|
@ -147,7 +147,7 @@ namespace Bit.Droid.Accessibility
|
||||||
return uri;
|
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)
|
if (addressNode?.Text == null)
|
||||||
{
|
{
|
||||||
|
@ -160,21 +160,13 @@ namespace Bit.Droid.Accessibility
|
||||||
uri = browser.GetUriFunction(addressNode.Text)?.Trim();
|
uri = browser.GetUriFunction(addressNode.Text)?.Trim();
|
||||||
if (uri != null && uri.Contains("."))
|
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);
|
return string.Concat("http://", uri);
|
||||||
if (parts.Length > 1)
|
|
||||||
{
|
|
||||||
var urlPart = parts.FirstOrDefault(p => p.StartsWith("http"));
|
|
||||||
if (urlPart != null)
|
|
||||||
{
|
|
||||||
uri = urlPart.Trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return uri;
|
return uri;
|
||||||
|
|
|
@ -85,15 +85,14 @@ namespace Bit.Core.Utilities
|
||||||
{
|
{
|
||||||
return null;
|
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))
|
if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri))
|
||||||
{
|
{
|
||||||
return uri;
|
return uri;
|
||||||
}
|
}
|
||||||
|
if (Uri.TryCreate("http://" + uriString, UriKind.Absolute, out var uri2))
|
||||||
|
{
|
||||||
|
return uri2;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue