s/[:'"]/_/g, momentary insanity i suppose. All i need do is replace /
with _ on output filenames and replace ' with '\'' on filenames that
will go to the shell surrouned by '' quotes, instead of being passed
directly into a program's argv.
fa-flacd:
(flac): Do / sanitization only, since we're not going through the
shell, but running flac directly.
flac2mp3:
(flac2mp3): We weren't sanitizing the input filename; start doing
so. Only do ' sanitization for input file and output id3tag
information, additionally do / sanitization on $outfile.
chdir($dir) or die("chdir($dir): $!");
$outfile = "$album";
chdir($dir) or die("chdir($dir): $!");
$outfile = "$album";
- for ($outfile) {
- s/\//_/g;
- s/:/_/g;
- s/'/_/g;
- s/"/_/g;
- }
verbose("Running flac\n");
$status = system('flac', '-o', "../$artist/$outfile.flac-tmp",
verbose("Running flac\n");
$status = system('flac', '-o', "../$artist/$outfile.flac-tmp",
my $track = shift;
my $skip_arg = shift;
my $until_arg = shift;
my $track = shift;
my $skip_arg = shift;
my $until_arg = shift;
- my $outfile = sprintf("$artist ($album) \%02s $title.mp3", $track);
- for ($outfile) {
- s/\//_/g;
- s/:/_/g;
- s/'/_/g;
- s/"/_/g;
+ # We'll be putting these in single quotes, so we need to escape
+ # any single quotes in the filename by closing the quote ('),
+ # putting an escaped quote (\'), and then reopening the quote (').
+ for ($fn, $title, $artist, $album, $date) {
+ s/'/'\\''/;
+ $outfile = sprintf("$artist ($album) \%02s $title.mp3", $track);
+ $outfile =~ s/\//_/g;
+
$until_arg ||= '';
# XXX
system("flac -cd $skip_arg $until_arg '$fn' | lame --preset standard --tt '$title' --ta '$artist' --tl '$album' --ty '$date' --tn $track - '$outfile'");
$until_arg ||= '';
# XXX
system("flac -cd $skip_arg $until_arg '$fn' | lame --preset standard --tt '$title' --ta '$artist' --tl '$album' --ty '$date' --tn $track - '$outfile'");