Follow-up improvements of 810219d3bf

master
Ansariel 2024-06-18 20:32:24 +02:00 committed by Andrey Lihatskiy
parent 810219d3bf
commit 7342ebf43a
2 changed files with 5 additions and 5 deletions

View File

@ -876,15 +876,15 @@ std::string LLDir::getTempFilename() const
} }
// static // static
std::string LLDir::getScrubbedFileName(const std::string uncleanFileName) std::string LLDir::getScrubbedFileName(std::string_view uncleanFileName)
{ {
std::string name(uncleanFileName); std::string name(uncleanFileName);
const std::string illegalChars(getForbiddenFileChars()); const std::string illegalChars(getForbiddenFileChars());
// replace any illegal file chars with and underscore '_' // replace any illegal file chars with and underscore '_'
for( const char &ch : illegalChars) for (const char& ch : illegalChars)
{ {
std::string::size_type j = -1; std::string::size_type j{ 0 };
while((j = name.find(ch)) != std::string::npos) while ((j = name.find(ch, j)) != std::string::npos)
{ {
name[j] = '_'; name[j] = '_';
} }

View File

@ -178,7 +178,7 @@ class LLDir
static std::string getDumpLogsDirPath(const std::string &file_name = ""); static std::string getDumpLogsDirPath(const std::string &file_name = "");
// For producing safe download file names from potentially unsafe ones // For producing safe download file names from potentially unsafe ones
static std::string getScrubbedFileName(const std::string uncleanFileName); static std::string getScrubbedFileName(std::string_view uncleanFileName);
static std::string getForbiddenFileChars(); static std::string getForbiddenFileChars();
void setDumpDir( const std::string& path ); void setDumpDir( const std::string& path );