mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +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;
|
||||
}
|
||||
|
||||
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 a new issue