Escape single quotes in filenames

This commit is contained in:
Peter Rice
2019-08-06 21:41:38 -04:00
parent 2ff23ed719
commit e1e220c975
3 changed files with 16 additions and 1 deletions

View File

@@ -96,3 +96,15 @@ void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible
}
}
}
void escapeSingleQuotes(std::string &filename)
{
for (size_t i = 0; i < filename.length(); ++i)
{
if (filename[i] == '\'')
{
filename.replace(i, 1, "'\\''");
i += 3;
}
}
}

View File

@@ -60,4 +60,6 @@ std::string getEnclosedString(const std::string &s, char a, char b, size_t *pos)
void removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible);
void escapeSingleQuotes(std::string &filename);
#endif // NCMPCPP_UTILITY_STRING_H