mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-27 11:15:43 -04:00
System: Fix incorrect sanitization of memcard filenames
This commit is contained in:
parent
315524a89c
commit
7b8704aba1
@ -36,20 +36,6 @@ MemoryCard::~MemoryCard()
|
|||||||
SaveIfChanged(false);
|
SaveIfChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MemoryCard::SanitizeGameTitleForFileName(const std::string_view& name)
|
|
||||||
{
|
|
||||||
std::string ret(name);
|
|
||||||
|
|
||||||
const u32 len = static_cast<u32>(ret.length());
|
|
||||||
for (u32 i = 0; i < len; i++)
|
|
||||||
{
|
|
||||||
if (ret[i] == '\\' || ret[i] == '/' || ret[i] == '?' || ret[i] == '*')
|
|
||||||
ret[i] = '_';
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
TickCount MemoryCard::GetSaveDelayInTicks()
|
TickCount MemoryCard::GetSaveDelayInTicks()
|
||||||
{
|
{
|
||||||
return System::GetTicksPerSecond() * SAVE_DELAY_IN_SECONDS;
|
return System::GetTicksPerSecond() * SAVE_DELAY_IN_SECONDS;
|
||||||
|
@ -20,8 +20,6 @@ public:
|
|||||||
|
|
||||||
static constexpr u32 STATE_SIZE = 1 + 1 + 2 + 1 + 1 + 1 + MemoryCardImage::DATA_SIZE + 1;
|
static constexpr u32 STATE_SIZE = 1 + 1 + 2 + 1 + 1 + 1 + MemoryCardImage::DATA_SIZE + 1;
|
||||||
|
|
||||||
static std::string SanitizeGameTitleForFileName(const std::string_view& name);
|
|
||||||
|
|
||||||
static std::unique_ptr<MemoryCard> Create();
|
static std::unique_ptr<MemoryCard> Create();
|
||||||
static std::unique_ptr<MemoryCard> Open(std::string_view filename);
|
static std::unique_ptr<MemoryCard> Open(std::string_view filename);
|
||||||
|
|
||||||
|
@ -3068,21 +3068,18 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
|
|||||||
// Playlist - use title if different.
|
// Playlist - use title if different.
|
||||||
if (HasMediaSubImages() && s_running_game_entry && s_running_game_title != s_running_game_entry->title)
|
if (HasMediaSubImages() && s_running_game_entry && s_running_game_title != s_running_game_entry->title)
|
||||||
{
|
{
|
||||||
card_path =
|
card_path = g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(s_running_game_title), slot);
|
||||||
g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(s_running_game_title), slot);
|
|
||||||
}
|
}
|
||||||
// Multi-disc game - use disc set name.
|
// Multi-disc game - use disc set name.
|
||||||
else if (s_running_game_entry && !s_running_game_entry->disc_set_name.empty())
|
else if (s_running_game_entry && !s_running_game_entry->disc_set_name.empty())
|
||||||
{
|
{
|
||||||
card_path = g_settings.GetGameMemoryCardPath(
|
card_path =
|
||||||
MemoryCard::SanitizeGameTitleForFileName(s_running_game_entry->disc_set_name), slot);
|
g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(s_running_game_entry->disc_set_name), slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// But prefer a disc-specific card if one already exists.
|
// But prefer a disc-specific card if one already exists.
|
||||||
std::string disc_card_path =
|
std::string disc_card_path = g_settings.GetGameMemoryCardPath(
|
||||||
g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(
|
Path::SanitizeFileName(s_running_game_entry ? s_running_game_entry->title : s_running_game_title), slot);
|
||||||
s_running_game_entry ? s_running_game_entry->title : s_running_game_title),
|
|
||||||
slot);
|
|
||||||
if (disc_card_path != card_path)
|
if (disc_card_path != card_path)
|
||||||
{
|
{
|
||||||
if (card_path.empty() || !g_settings.memory_card_use_playlist_title ||
|
if (card_path.empty() || !g_settings.memory_card_use_playlist_title ||
|
||||||
@ -3122,8 +3119,7 @@ std::unique_ptr<MemoryCard> System::GetMemoryCardForSlot(u32 slot, MemoryCardTyp
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Host::RemoveKeyedOSDMessage(std::move(message_key));
|
Host::RemoveKeyedOSDMessage(std::move(message_key));
|
||||||
return MemoryCard::Open(
|
return MemoryCard::Open(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(file_title).c_str(), slot));
|
||||||
g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(file_title).c_str(), slot));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,12 +856,11 @@ void MainWindow::populateGameListContextMenu(const GameList::Entry* entry, QWidg
|
|||||||
break;
|
break;
|
||||||
case MemoryCardType::PerGameTitle:
|
case MemoryCardType::PerGameTitle:
|
||||||
{
|
{
|
||||||
paths[i] = QString::fromStdString(
|
paths[i] = QString::fromStdString(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(entry->title), i));
|
||||||
g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(entry->title), i));
|
|
||||||
if (!entry->disc_set_name.empty() && g_settings.memory_card_use_playlist_title && !QFile::exists(paths[i]))
|
if (!entry->disc_set_name.empty() && g_settings.memory_card_use_playlist_title && !QFile::exists(paths[i]))
|
||||||
{
|
{
|
||||||
paths[i] = QString::fromStdString(
|
paths[i] =
|
||||||
g_settings.GetGameMemoryCardPath(MemoryCard::SanitizeGameTitleForFileName(entry->disc_set_name), i));
|
QString::fromStdString(g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(entry->disc_set_name), i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -869,8 +868,8 @@ void MainWindow::populateGameListContextMenu(const GameList::Entry* entry, QWidg
|
|||||||
case MemoryCardType::PerGameFileTitle:
|
case MemoryCardType::PerGameFileTitle:
|
||||||
{
|
{
|
||||||
const std::string display_name(FileSystem::GetDisplayNameFromPath(entry->path));
|
const std::string display_name(FileSystem::GetDisplayNameFromPath(entry->path));
|
||||||
paths[i] = QString::fromStdString(g_settings.GetGameMemoryCardPath(
|
paths[i] = QString::fromStdString(
|
||||||
MemoryCard::SanitizeGameTitleForFileName(Path::GetFileTitle(display_name)), i));
|
g_settings.GetGameMemoryCardPath(Path::SanitizeFileName(Path::GetFileTitle(display_name)), i));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1086,8 +1085,7 @@ void MainWindow::onCheatsActionTriggered()
|
|||||||
void MainWindow::onCheatsMenuAboutToShow()
|
void MainWindow::onCheatsMenuAboutToShow()
|
||||||
{
|
{
|
||||||
m_ui.menuCheats->clear();
|
m_ui.menuCheats->clear();
|
||||||
connect(m_ui.menuCheats->addAction(tr("Cheat Manager")), &QAction::triggered, this,
|
connect(m_ui.menuCheats->addAction(tr("Cheat Manager")), &QAction::triggered, this, &MainWindow::openCheatManager);
|
||||||
&MainWindow::openCheatManager);
|
|
||||||
m_ui.menuCheats->addSeparator();
|
m_ui.menuCheats->addSeparator();
|
||||||
populateCheatsMenu(m_ui.menuCheats);
|
populateCheatsMenu(m_ui.menuCheats);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user