Commit 87a8a3e2 authored by Max Kellermann's avatar Max Kellermann

PlaylistFile: move memchr() call to class Path

parent e9125ef8
...@@ -169,11 +169,13 @@ LoadPlaylistFileInfo(PlaylistInfo &info, ...@@ -169,11 +169,13 @@ LoadPlaylistFileInfo(PlaylistInfo &info,
const Path parent_path_fs, const Path parent_path_fs,
const Path name_fs) const Path name_fs)
{ {
if (name_fs.HasNewline())
return false;
const auto *const name_fs_str = name_fs.c_str(); const auto *const name_fs_str = name_fs.c_str();
const size_t name_length = name_fs.length(); const size_t name_length = name_fs.length();
if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX) || if (name_length < ARRAY_SIZE(PLAYLIST_FILE_SUFFIX))
memchr(name_fs_str, '\n', name_length) != nullptr)
return false; return false;
if (!StringEndsWith(name_fs_str, PLAYLIST_FILE_SUFFIX)) if (!StringEndsWith(name_fs_str, PLAYLIST_FILE_SUFFIX))
......
...@@ -123,6 +123,16 @@ public: ...@@ -123,6 +123,16 @@ public:
} }
/** /**
* Does the path contain a newline character? (Which is
* usually rejected by MPD because its protocol cannot
* transfer newline characters).
*/
gcc_pure
bool HasNewline() const {
return strchr(value, '\n') != nullptr;
}
/**
* Convert the path to UTF-8. * Convert the path to UTF-8.
* Returns empty string on error or if this instance is "nulled" * Returns empty string on error or if this instance is "nulled"
* (#IsNull returns true). * (#IsNull returns true).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment