Fixed !WriteKeyValue with "@\"

This commit is contained in:
Birunthan Mohanathas 2012-05-21 12:07:50 +03:00
parent f2318c4a65
commit 4d18141696
2 changed files with 109 additions and 108 deletions

View File

@ -488,17 +488,23 @@ void CRainmeter::Bang_TrayMenu()
*/ */
void CRainmeter::Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow) void CRainmeter::Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow)
{ {
if (args.size() < 4) if (args.size() == 3 && meterWindow)
{ {
if (!meterWindow) return;
// Add the config filepath to the args // Add the config filepath to the args
args.push_back(meterWindow->GetSkinFilePath()); args.push_back(meterWindow->GetSkinFilePath());
} }
else if (args.size() < 4)
if (args.size() > 3)
{ {
const std::wstring& strIniFile = args[3]; Log(LOG_ERROR, L"!WriteKeyValue: Invalid parameters");
return;
}
std::wstring& strIniFile = args[3];
if (meterWindow)
{
meterWindow->MakePathAbsolute(strIniFile);
}
const WCHAR* iniFile = strIniFile.c_str(); const WCHAR* iniFile = strIniFile.c_str();
if (strIniFile.find(L"..\\") != std::wstring::npos || strIniFile.find(L"../") != std::wstring::npos) if (strIniFile.find(L"..\\") != std::wstring::npos || strIniFile.find(L"../") != std::wstring::npos)
@ -608,11 +614,6 @@ void CRainmeter::Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindo
LogWithArgs(LOG_ERROR, L"!WriteKeyValue: Failed to write to: %s", iniFile); LogWithArgs(LOG_ERROR, L"!WriteKeyValue: Failed to write to: %s", iniFile);
} }
} }
}
else
{
Log(LOG_ERROR, L"!WriteKeyValue: Invalid parameters");
}
} }
/* /*
@ -1953,7 +1954,7 @@ void CRainmeter::ExecuteBang(const WCHAR* bang, std::vector<std::wstring>& args,
} }
else if (_wcsicmp(bang, L"SetWallpaper") == 0) else if (_wcsicmp(bang, L"SetWallpaper") == 0)
{ {
Bang_SetWallpaper(args); Bang_SetWallpaper(args, meterWindow);
} }
else if (_wcsicmp(bang, L"About") == 0) else if (_wcsicmp(bang, L"About") == 0)
{ {

View File

@ -241,7 +241,7 @@ private:
void Bang_ToggleConfig(std::vector<std::wstring>& args); void Bang_ToggleConfig(std::vector<std::wstring>& args);
void Bang_DeactivateConfigGroup(std::vector<std::wstring>& args); void Bang_DeactivateConfigGroup(std::vector<std::wstring>& args);
void Bang_SetClip(std::vector<std::wstring>& args); void Bang_SetClip(std::vector<std::wstring>& args);
void Bang_SetWallpaper(std::vector<std::wstring>& args); void Bang_SetWallpaper(std::vector<std::wstring>& args, CMeterWindow* meterWindow);
void Bang_SkinMenu(std::vector<std::wstring>& args, CMeterWindow* meterWindow); void Bang_SkinMenu(std::vector<std::wstring>& args, CMeterWindow* meterWindow);
void Bang_TrayMenu(); void Bang_TrayMenu();
void Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow); void Bang_WriteKeyValue(std::vector<std::wstring>& args, CMeterWindow* meterWindow);