Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'CPP/7zip/Archive/Zip/ZipHandlerOut.cpp')
-rw-r--r--CPP/7zip/Archive/Zip/ZipHandlerOut.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
index ae58cbe2..f1c8b227 100644
--- a/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
+++ b/CPP/7zip/Archive/Zip/ZipHandlerOut.cpp
@@ -34,15 +34,16 @@ STDMETHODIMP CHandler::GetFileTimeType(UInt32 *timeType)
return S_OK;
}
-static bool IsAsciiString(const UString &s)
+static bool IsSimpleAsciiString(const wchar_t *s)
{
- for (unsigned i = 0; i < s.Len(); i++)
+ for (;;)
{
- wchar_t c = s[i];
+ wchar_t c = *s++;
+ if (c == 0)
+ return true;
if (c < 0x20 || c > 0x7F)
return false;
}
- return true;
}
#define COM_TRY_BEGIN2 try {
@@ -180,11 +181,8 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (tryUtf8)
{
- unsigned i;
- for (i = 0; i < name.Len() && (unsigned)name[i] < 0x80; i++);
- ui.IsUtf8 = (i != name.Len());
- if (!ConvertUnicodeToUTF8(name, ui.Name))
- return E_INVALIDARG;
+ ui.IsUtf8 = !name.IsAscii();
+ ConvertUnicodeToUTF8(name, ui.Name);
}
if (ui.Name.Len() >= (1 << 16))
@@ -249,10 +247,10 @@ STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numIt
if (!m_ForceAesMode)
options.IsAesMode = thereAreAesUpdates;
- if (!IsAsciiString((BSTR)password))
+ if (!IsSimpleAsciiString(password))
return E_INVALIDARG;
if (password)
- options.Password = UnicodeStringToMultiByte((BSTR)password, CP_OEMCP);
+ options.Password = UnicodeStringToMultiByte((LPCOLESTR)password, CP_OEMCP);
if (options.IsAesMode)
{
if (options.Password.Len() > NCrypto::NWzAes::kPasswordSizeMax)
@@ -297,7 +295,7 @@ static const CMethodIndexToName k_SupportedMethods[] =
{ NFileHeader::NCompressionMethod::kPPMd, "ppmd" }
};
-STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *values, UInt32 numProps)
+STDMETHODIMP CHandler::SetProperties(const wchar_t * const *names, const PROPVARIANT *values, UInt32 numProps)
{
InitMethodProps();
#ifndef _7ZIP_ST
@@ -318,7 +316,7 @@ STDMETHODIMP CHandler::SetProperties(const wchar_t **names, const PROPVARIANT *v
UInt32 level = 9;
RINOK(ParsePropToUInt32(name.Ptr(1), prop, level));
_props.Level = level;
- _props.MethodInfo.AddLevelProp(level);
+ _props.MethodInfo.AddProp_Level(level);
}
else if (name == L"m")
{