Audit culture bugs (#7707)

* Added comments and fixed CultureInfo /  StringComparison where appropriate

* Addressed comments

* Fixed comment
This commit is contained in:
Avneet Kaur
2020-10-30 16:43:09 -07:00
committed by GitHub
parent bd34127cd4
commit 2c5b9b4d52
54 changed files with 160 additions and 28 deletions

View File

@@ -17,6 +17,8 @@ namespace Microsoft.Plugin.Folder.Sources
private static IEnumerable<string> InitialDriverList()
{
var directorySeparatorChar = System.IO.Path.DirectorySeparatorChar;
// Using InvariantCulture since this is internal
return DriveInfo.GetDrives()
.Select(driver => driver.Name.ToLower(CultureInfo.InvariantCulture).TrimEnd(directorySeparatorChar));
}

View File

@@ -27,6 +27,7 @@ namespace Microsoft.Plugin.Folder.Sources
throw new ArgumentNullException(paramName: nameof(query));
}
// Using OrdinalIgnoreCase since this is internal
return _folderLinks.FolderLinks()
.Where(x => x.Nickname.StartsWith(query, StringComparison.OrdinalIgnoreCase));
}
@@ -38,7 +39,8 @@ namespace Microsoft.Plugin.Folder.Sources
throw new ArgumentNullException(nameof(search));
}
if (search.StartsWith(@"\\", StringComparison.InvariantCulture))
// Using Ordinal this is internal and we're comparing symbols
if (search.StartsWith(@"\\", StringComparison.Ordinal))
{ // share folder
return true;
}
@@ -48,6 +50,7 @@ namespace Microsoft.Plugin.Folder.Sources
if (driverNames.Any())
{
// Using InvariantCultureIgnoreCase since this is searching for drive names
if (driverNames.Any(dn => search.StartsWith(dn, StringComparison.InvariantCultureIgnoreCase)))
{
// normal drive letter