Escape single quotes in filenames
This commit is contained in:
@@ -326,6 +326,7 @@ void Lyrics::edit()
|
|||||||
GNUC_UNUSED int res;
|
GNUC_UNUSED int res;
|
||||||
std::string command;
|
std::string command;
|
||||||
std::string filename = lyricsFilename(m_song);
|
std::string filename = lyricsFilename(m_song);
|
||||||
|
escapeSingleQuotes(filename);
|
||||||
if (Config.use_console_editor)
|
if (Config.use_console_editor)
|
||||||
{
|
{
|
||||||
command = Config.external_editor + " '" + filename + "'";
|
command = Config.external_editor + " '" + filename + "'";
|
||||||
@@ -337,7 +338,7 @@ void Lyrics::edit()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
command = "nohup " + Config.external_editor
|
command = "nohup " + Config.external_editor
|
||||||
+ " \"" + filename + "\" > /dev/null 2>&1 &";
|
+ " '" + filename + "' > /dev/null 2>&1 &";
|
||||||
res = system(command.c_str());
|
res = system(command.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -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 removeInvalidCharsFromFilename(std::string &filename, bool win32_compatible);
|
||||||
|
|
||||||
|
void escapeSingleQuotes(std::string &filename);
|
||||||
|
|
||||||
#endif // NCMPCPP_UTILITY_STRING_H
|
#endif // NCMPCPP_UTILITY_STRING_H
|
||||||
|
|||||||
Reference in New Issue
Block a user