Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions APIHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,23 @@ class ChronosFileOpenDialog : public IFileOpenDialog
}
}

int maxFileLength = theApp.m_AppSettings.GetMaxUploadFileLength();
if (maxFileLength > 0)
{
WCHAR* ptrFile = NULL;
ptrFile = PathFindFileNameW((LPCWSTR)strSelPathOriginal);
CString fileName(ptrFile);
int fileLength = fileName.GetLength();
if (fileLength > maxFileLength)
{
CString strCaption(theApp.m_strThisAppName);
CString strMsg;
strMsg.Format(L"ファイル名が長すぎるためアップロードできません。\n\n選択したファイルの名前: %d文字\n指定可能なファイル名の最大値: %d文字", fileLength, maxFileLength);
::MessageBoxW(hwndOwner, strMsg, strCaption, MB_OK | MB_ICONWARNING);
continue;
}
}

if (theApp.m_AppSettings.IsEnableLogging() && theApp.m_AppSettings.IsEnableUploadLogging())
{
WCHAR* ptrFile = NULL;
Expand Down Expand Up @@ -997,6 +1014,21 @@ static BOOL WINAPI Hook_GetOpenFileNameW(
}
}

int maxFileLength = theApp.m_AppSettings.GetMaxUploadFileLength();
if (maxFileLength > 0)
{
WCHAR* ptrFile = NULL;
ptrFile = PathFindFileNameW(lpofn->lpstrFile);
CString fileName(ptrFile);
int fileLength = fileName.GetLength();
if (fileLength > maxFileLength)
{
strMsg.Format(L"ファイル名が長すぎるためアップロードできません。\n\n選択したファイルの名前: %d文字\n指定可能なファイル名の最大値: %d文字", fileLength, maxFileLength);
::MessageBoxW(lpofn->hwndOwner, strMsg, strCaption, MB_OK | MB_ICONWARNING);
continue;
}
}

PathRemoveFileSpec(strSelPath.GetBuffer());
strSelPath.ReleaseBuffer();
theApp.m_strLastSelectUploadFolderPath = strSelPath;
Expand Down
17 changes: 17 additions & 0 deletions sbcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ class AppSettings
WindowCountLimit = 0;
EnableMediaAccessByApproval = static_cast<int>(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS);
EnableMediaAccessPermission = static_cast<int>(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS);
MaxUploadFileLength = 0;

EnableDownloadRestriction = 0;
EnableUploadRestriction = 0;
Expand Down Expand Up @@ -1035,6 +1036,7 @@ class AppSettings
Data.MemoryUsageLimit = MemoryUsageLimit;
Data.WindowCountLimit = WindowCountLimit;
Data.EnableMediaAccessPermission = EnableMediaAccessPermission;
Data.MaxUploadFileLength = MaxUploadFileLength;

Data.EnableDownloadRestriction = EnableDownloadRestriction;
Data.EnableUploadRestriction = EnableUploadRestriction;
Expand Down Expand Up @@ -1122,6 +1124,7 @@ class AppSettings
int WindowCountLimit;
int EnableMediaAccessByApproval; // deprecated
int EnableMediaAccessPermission;
int MaxUploadFileLength;

//リダイレクト設定
int EnableURLRedirect;
Expand Down Expand Up @@ -1229,6 +1232,7 @@ class AppSettings
MemoryUsageLimit = 2040;
WindowCountLimit = 60;
EnableMediaAccessPermission = static_cast<int>(AppSettings::MediaAccessPermission::NO_MEDIA_ACCESS);
MaxUploadFileLength = 0;

/////////////////////////////////////////////////////////////////////////////////////////////////
//リダイレクト設定
Expand Down Expand Up @@ -1657,6 +1661,17 @@ class AppSettings
continue;
}

if (strTemp2.CompareNoCase(_T("MaxUploadFileLength")) == 0)
{
int iW = 0;
iW = _ttoi(strTemp3);
if (0 <= iW && iW <= MAX_PATH - 1)
MaxUploadFileLength = iW;
else
MaxUploadFileLength = 0;
continue;
}

if (strTemp2.CompareNoCase(_T("EnableDownloadRestriction")) == 0)
{
EnableDownloadRestriction = (strTemp3 == _T("1")) ? TRUE : FALSE;
Expand Down Expand Up @@ -2020,6 +2035,7 @@ class AppSettings

strRet += _T("# non GUI parameters\n");
strRet += EXTVAL(EnableMediaAccessPermission);
strRet += EXTVAL(MaxUploadFileLength);
strRet += EXTVAL(UploadBasePath);
strRet += EXTVAL(ExitMessage);
strRet += EXTVAL(unZipMessage);
Expand Down Expand Up @@ -2078,6 +2094,7 @@ class AppSettings
inline int GetMemoryUsageLimit() { return MemoryUsageLimit; }
inline int GetWindowCountLimit() { return WindowCountLimit; }
inline int GetMediaAccessPermission() { return EnableMediaAccessPermission; }
inline int GetMaxUploadFileLength() { return MaxUploadFileLength; }

inline BOOL IsEnableDownloadRestriction() { return EnableDownloadRestriction; }
inline BOOL IsEnableUploadRestriction() { return EnableUploadRestriction; }
Expand Down