From 4d626c294c4783d454e27ea4e5614037dac8576e Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 1 Nov 2025 20:24:25 -0700 Subject: Use CompareStringOrdinal() instead of CompareString() case-insensitive This commit moves to the modern CompareStringOrdinal() for all case-insensitve uses of CompareString() with the invariant locale. Partially resolves 6947 --- src/libs/dutil/WixToolset.DUtil/acl2util.cpp | 2 +- src/libs/dutil/WixToolset.DUtil/apuputil.cpp | 10 +++++----- src/libs/dutil/WixToolset.DUtil/iis7util.cpp | 6 +++--- src/libs/dutil/WixToolset.DUtil/path2utl.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/libs') diff --git a/src/libs/dutil/WixToolset.DUtil/acl2util.cpp b/src/libs/dutil/WixToolset.DUtil/acl2util.cpp index 598f12e7..e62a03d4 100644 --- a/src/libs/dutil/WixToolset.DUtil/acl2util.cpp +++ b/src/libs/dutil/WixToolset.DUtil/acl2util.cpp @@ -106,7 +106,7 @@ extern "C" HRESULT DAPI AclGetAccountSidStringEx( HRESULT hrLength = ::StringCchLengthW(wzAccount, STRSAFE_MAX_CCH, reinterpret_cast(&cchAccount)); AclExitOnFailure(hrLength, "Failed to get the length of the account name."); - if (11 < cchAccount && CSTR_EQUAL == CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, L"NT SERVICE\\", 11, wzAccount, 11)) + if (11 < cchAccount && CSTR_EQUAL == CompareStringOrdinal(L"NT SERVICE\\", 11, wzAccount, 11, TRUE)) { // If the service is not installed then LookupAccountName doesn't resolve the SID, but we can calculate it. LPCWSTR wzServiceName = &wzAccount[11]; diff --git a/src/libs/dutil/WixToolset.DUtil/apuputil.cpp b/src/libs/dutil/WixToolset.DUtil/apuputil.cpp index eb96d515..62cf4d06 100644 --- a/src/libs/dutil/WixToolset.DUtil/apuputil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/apuputil.cpp @@ -112,7 +112,7 @@ extern "C" HRESULT DAPI ApupAllocChainFromAtom( } // Trim the unused entries from the end, if any of the entries failed to parse or validate - if (pChain->cEntries != pFeed->cEntries) + if (pChain->cEntries != pFeed->cEntries) { if (pChain->cEntries > 0) { @@ -354,22 +354,22 @@ static HRESULT ParseEnclosure( dwDigestLength = 0; if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, 0, L"algorithm", -1, pAttribute->wzAttribute, -1)) { - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"md5", -1, pAttribute->wzValue, -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(L"md5", -1, pAttribute->wzValue, -1, TRUE)) { pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_MD5; dwDigestLength = MD5_HASH_LEN; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha1", -1, pAttribute->wzValue, -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha1", -1, pAttribute->wzValue, -1, TRUE)) { pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA1; dwDigestLength = SHA1_HASH_LEN; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha256", -1, pAttribute->wzValue, -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha256", -1, pAttribute->wzValue, -1, TRUE)) { pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA256; dwDigestLength = SHA256_HASH_LEN; } - else if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, L"sha512", -1, pAttribute->wzValue, -1)) + else if (CSTR_EQUAL == ::CompareStringOrdinal(L"sha512", -1, pAttribute->wzValue, -1, TRUE)) { pEnclosure->digestAlgorithm = APUP_HASH_ALGORITHM_SHA512; dwDigestLength = SHA512_HASH_LEN; diff --git a/src/libs/dutil/WixToolset.DUtil/iis7util.cpp b/src/libs/dutil/WixToolset.DUtil/iis7util.cpp index d0a0b000..b0dc1444 100644 --- a/src/libs/dutil/WixToolset.DUtil/iis7util.cpp +++ b/src/libs/dutil/WixToolset.DUtil/iis7util.cpp @@ -222,7 +222,7 @@ BOOL DAPI CompareVariantPath( IisExitOnFailure(hr, "Failed to expand path %ls", pVariant2->bstrVal); } - fEqual = CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzValue1, -1, wzValue2, -1); + fEqual = CSTR_EQUAL == ::CompareStringOrdinal(wzValue1, -1, wzValue2, -1, TRUE); LExit: ReleaseNullStr(wzValue1); @@ -258,7 +258,7 @@ extern "C" BOOL DAPI Iis7IsMatchingAppHostElement( hr = pElement->get_Name(&bstrElementName); IisExitOnFailure(hr, "Failed to get name of element"); - if (CSTR_EQUAL != ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, pComparison->sczElementName, -1, bstrElementName, -1)) + if (CSTR_EQUAL != ::CompareStringOrdinal(pComparison->sczElementName, -1, bstrElementName, -1, TRUE)) { ExitFunction(); } @@ -293,7 +293,7 @@ BOOL DAPI IsMatchingAppHostMethod( Assert(bstrName); - if (CSTR_EQUAL == ::CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, wzMethodName, -1, bstrName, -1)) + if (CSTR_EQUAL == ::CompareStringOrdinal(wzMethodName, -1, bstrName, -1, TRUE)) { fResult = TRUE; } diff --git a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp index d83a4578..06df8617 100644 --- a/src/libs/dutil/WixToolset.DUtil/path2utl.cpp +++ b/src/libs/dutil/WixToolset.DUtil/path2utl.cpp @@ -306,7 +306,7 @@ DAPI_(HRESULT) PathCompareCanonicalized( hr = PathCanonicalizeForComparison(wzPath2, dwDefaultFlags, &sczCanonicalized2); PathExitOnFailure(hr, "Failed to canonicalize wzPath2."); - nResult = ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczCanonicalized1, -1, sczCanonicalized2, -1); + nResult = ::CompareStringOrdinal(sczCanonicalized1, -1, sczCanonicalized2, -1, TRUE); PathExitOnNullWithLastError(nResult, hr, "Failed to compare canonicalized paths."); *pfEqual = CSTR_EQUAL == nResult; @@ -364,7 +364,7 @@ DAPI_(HRESULT) PathDirectoryContainsPath( ExitFunction1(hr = S_FALSE); } - if (CSTR_EQUAL != ::CompareStringW(LOCALE_NEUTRAL, NORM_IGNORECASE, sczCanonicalizedDirectory, (DWORD)cchDirectory, sczCanonicalizedPath, (DWORD)cchDirectory)) + if (CSTR_EQUAL != ::CompareStringOrdinal(sczCanonicalizedDirectory, (DWORD)cchDirectory, sczCanonicalizedPath, (DWORD)cchDirectory, TRUE)) { ExitFunction1(hr = S_FALSE); } -- cgit v1.2.3-55-g6feb