Replace slashes with underscores when organising files. Fixes issue #503

This commit is contained in:
David Sansome 2010-07-24 13:56:49 +00:00
parent aba01f63c7
commit 692e5715e3
2 changed files with 10 additions and 0 deletions

View File

@ -144,6 +144,10 @@ QString OrganiseFormat::TagValue(const QString &tag, const Song &song) const {
if (tag == "track" && value.length() == 1)
value.prepend('0');
// Replace characters that really shouldn't be in paths
value.replace('/', '_');
value.replace('\\', '_');
return value;
}

View File

@ -139,3 +139,9 @@ TEST_F(OrganiseFormatTest, TrackNumberPadding) {
song_.set_track(0);
EXPECT_EQ("", format_.GetFilenameForSong(song_));
}
TEST_F(OrganiseFormatTest, ReplaceSlashes) {
format_.set_format("%title");
song_.set_title("foo/bar\\baz");
EXPECT_EQ("foo_bar_baz", format_.GetFilenameForSong(song_));
}