From a45d375f6069c5e32d643f67c4004c041aff4cb1 Mon Sep 17 00:00:00 2001 From: Whindmar Saksit Date: Mon, 22 Jul 2024 16:20:31 +0200 Subject: [PATCH] [RAPPS] Fix CAB codepage handling (#7165) - MultiByteToWide parameter bug. - Use CP_UTF8 to convert cab filenames if the UTF attribute is set. --- base/applications/rapps/cabinet.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/applications/rapps/cabinet.cpp b/base/applications/rapps/cabinet.cpp index 46b9484f161..3163f6bc4c0 100644 --- a/base/applications/rapps/cabinet.cpp +++ b/base/applications/rapps/cabinet.cpp @@ -47,7 +47,7 @@ MultiByteToWide(const CStringA &szSource, CStringW &szDest, UINT Codepage) return FALSE; // do the actual conversion - sz = MultiByteToWideChar(CP_UTF8, 0, szSource, -1, szDest.GetBuffer(sz), sz); + sz = MultiByteToWideChar(Codepage, 0, szSource, -1, szDest.GetBuffer(sz), sz); szDest.ReleaseBuffer(); return sz != 0; @@ -160,7 +160,8 @@ FNFDINOTIFY(fnNotify) // Append the destination directory to the file name. MultiByteToWide(pND->OutputDir, szExtractDir, CP_UTF8); - MultiByteToWide(pfdin->psz1, szCabFileName, CP_ACP); + UINT codepage = (pfdin->attribs & _A_NAME_IS_UTF) ? CP_UTF8 : CP_ACP; + MultiByteToWide(pfdin->psz1, szCabFileName, codepage); if (!NotifyFileExtractCallback(szCabFileName, pfdin->cb, pfdin->attribs, pND->Callback, pND->CallerCookie))