]> diplodocus.org Git - flac-archive/blobdiff - fa-flacd
Sanitize filename sanitization and quoting. I'm not sure why i was
[flac-archive] / fa-flacd
index c3413e543af21f6568fd3977de14362074344d4d..822f6283c9210ea61cac2aea960d69cdc60373f7 100755 (executable)
--- a/fa-flacd
+++ b/fa-flacd
@@ -70,6 +70,7 @@ sub flac {
     my $artist;
     my $album;
     my @tags;
+    my $outfile;
     my $status;
 
     verbose("Renaming $dir/tags\n");
@@ -84,8 +85,11 @@ sub flac {
     verbose("chdir($dir)\n");
     chdir($dir) or die("chdir($dir): $!");
 
+    $outfile = "$album";
+    $outfile =~ s/\//_/g;
+
     verbose("Running flac\n");
-    $status = system('flac', '-o', "../$artist/$album.flac-tmp",
+    $status = system('flac', '-o', "../$artist/$outfile.flac-tmp",
                      '--delete-input-file', '-V', '--cuesheet',
                      'cue', '--no-padding', '--best',
                      map({ ('-T', $_) } @tags),
@@ -101,15 +105,15 @@ sub flac {
     verbose("Cleaning up $dir\n");
     unlink('using-tags') or die("unlink(using-tags): $!");
     unlink('cue') or die("unlink(cue): $!");
-    rename('toc', "../$artist/$album.toc")
-      or die("rename(toc, ../$artist/$album.toc): $!");
-    rename('log', "../$artist/$album.log")
-      or die("rename(log, ../$artist/$album.log): $!");
+    rename('toc', "../$artist/$outfile.toc")
+      or die("rename(toc, ../$artist/$outfile.toc): $!");
+    rename('log', "../$artist/$outfile.log")
+      or die("rename(log, ../$artist/$outfile.log): $!");
     chdir('..') or die("chdir(..): $!");
     rmdir($dir) or die("rmdir($dir): $!");
 
-    rename("$artist/$album.flac-tmp", "$artist/$album.flac")
-      or die("rename($artist/$album.flac-tmp, $artist/$album.flac): $!");
+    rename("$artist/$outfile.flac-tmp", "$artist/$outfile.flac")
+      or die("rename($artist/$outfile.flac-tmp, $artist/$outfile.flac): $!");
 
     return 0;
 }