Skip to content

Commit

Permalink
Fixed improper caase conversion of strings leading to encoding bugs (#71
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nefarius authored Nov 9, 2024
1 parent c1b83bb commit 63ebe2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/PnP/Devcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static unsafe bool FindInDeviceClassByHardwareId(Guid target, string hard
throw new ConfigManagerException("Failed to get device ID.", ret);
}

string instanceId = new string(ptrInstanceBuf).ToUpper();
string instanceId = new string(ptrInstanceBuf).ToUpperInvariant();

PnPDevice device = PnPDevice.GetDeviceByInstanceId(
instanceId,
Expand All @@ -116,11 +116,11 @@ public static unsafe bool FindInDeviceClassByHardwareId(Guid target, string hard
continue;
}

List<string> hardwareIds = property.Select(id => id.ToUpper()).ToList();
List<string> hardwareIds = property.Select(id => id.ToUpperInvariant()).ToList();

if (
/* partial match */
(allowPartial && hardwareIds.Any(id => id.Contains(hardwareId.ToUpper()))) ||
(allowPartial && hardwareIds.Any(id => id.Contains(hardwareId.ToUpperInvariant()))) ||
/* exact match */
(!allowPartial && hardwareIds.Contains(hardwareId, StringComparer.OrdinalIgnoreCase))
)
Expand Down Expand Up @@ -198,7 +198,7 @@ ref da
{
IntPtr pDevicePathName = detailDataBuffer + 4;

path = (Marshal.PtrToStringAuto(pDevicePathName) ?? string.Empty).ToUpper();
path = (Marshal.PtrToStringAuto(pDevicePathName) ?? string.Empty).ToUpperInvariant();

if (memberIndex == instance)
{
Expand All @@ -214,7 +214,7 @@ ref da
char* ptrInstanceBuf = stackalloc char[(int)nBytes];

PInvoke.CM_Get_Device_IDW(da.DevInst, ptrInstanceBuf, nBytes, 0);
instanceId = new string(ptrInstanceBuf).ToUpper();
instanceId = new string(ptrInstanceBuf).ToUpperInvariant();

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PnP/PnPDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public unsafe void Remove()
/// @"Nefarius\VirtualPad" // VirtualPad
/// };
///
/// return hardwareIds.Any(id =&gt; excludedIds.Contains(id.ToUpper()));
/// return hardwareIds.Any(id =&gt; excludedIds.Contains(id.ToUpperInvariant()));
/// });
/// </example>
public bool IsVirtual(Func<IPnPDevice, bool>? excludeIfMatches = default)
Expand Down

0 comments on commit 63ebe2c

Please sign in to comment.