everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: <dtas-all@nongnu.org>
Subject: [PATCH 2/3] escape INFILE and related environment variables
Date: Mon, 13 Apr 2015 01:04:23 +0000	[thread overview]
Message-ID: <1428887064-18715-3-git-send-email-e@80x24.org> (raw)
In-Reply-To: <1428887064-18715-1-git-send-email-e@80x24.org>

We may expand them, so ensure they're properly escaped, first
for use in shell snippets.
---
 lib/dtas/partstats.rb           | 2 +-
 lib/dtas/source/av_ff_common.rb | 2 +-
 lib/dtas/source/sox.rb          | 2 +-
 lib/dtas/splitfx.rb             | 6 ++++--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/dtas/partstats.rb b/lib/dtas/partstats.rb
index 9d3312b..bc13480 100644
--- a/lib/dtas/partstats.rb
+++ b/lib/dtas/partstats.rb
@@ -55,7 +55,7 @@ class DTAS::PartStats
     rd, wr = IO.pipe
     env = opts[:env]
     env = env ? env.dup : {}
-    env["INFILE"] = @infile
+    env["INFILE"] = xs(@infile)
     env["TRIMFX"] = "trim #{trim_part.tbeg}s #{trim_part.tlen}s"
     opts = { pgroup: true, close_others: true, err: wr }
     pid = spawn(env, CMD, opts)
diff --git a/lib/dtas/source/av_ff_common.rb b/lib/dtas/source/av_ff_common.rb
index 189e135..9f29b02 100644
--- a/lib/dtas/source/av_ff_common.rb
+++ b/lib/dtas/source/av_ff_common.rb
@@ -158,7 +158,7 @@ module DTAS::Source::AvFfCommon # :nodoc:
 
     e["PROBE"] = @probe_harder ? @probe_harder.join(' ') : nil
     # make sure these are visible to the source command...
-    e["INFILE"] = @infile
+    e["INFILE"] = xs(@infile)
     e["AMAP"] = amap
     e["SSPOS"] = sspos
     e["RGFX"] = rg_state.effect(self) || nil
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index 91a3c40..6f02f99 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -78,7 +78,7 @@ class DTAS::Source::Sox # :nodoc:
   def src_spawn(player_format, rg_state, opts)
     raise "BUG: #{self.inspect}#src_spawn called twice" if @to_io
     e = @env.merge!(player_format.to_env)
-    e["INFILE"] = @infile
+    e["INFILE"] = xs(@infile)
 
     # make sure these are visible to the "current" command...
     e["TRIMFX"] = trimfx
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 022fbfe..fcd0028 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -362,8 +362,10 @@ class DTAS::SplitFX # :nodoc:
   end
 
   def infile_env(env, infile)
-    env["INFILE"] = infile
-    env["INDIR"], env["INBASE"] = File.split(File.expand_path(infile))
+    env["INFILE"] = xs(infile)
+    dir, base = File.split(File.expand_path(infile))
+    env["INDIR"] = xs(dir)
+    env["INBASE"] = xs(base)
   end
 
   def _expand_cmd(env, command)
-- 
EW



  parent reply	other threads:[~2015-04-13  1:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-13  1:04 [PATCH 0/3] filename escaping fixups Eric Wong
2015-04-13  1:04 ` [PATCH 1/3] xs: allow taking a string as input Eric Wong
2015-04-13  1:04 ` Eric Wong [this message]
2015-04-13  1:04 ` [PATCH 3/3] cleanup: avoid redundant Array conversion for escapes Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/dtas/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1428887064-18715-3-git-send-email-e@80x24.org \
    --to=e@80x24.org \
    --cc=dtas-all@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).