everything related to duct tape audio suite (dtas)
 help / color / mirror / Atom feed
* [PATCH 0/3] filename escaping fixups
@ 2015-04-13  1:04 Eric Wong
  2015-04-13  1:04 ` [PATCH 1/3] xs: allow taking a string as input Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2015-04-13  1:04 UTC (permalink / raw)
  To: dtas-all

There was a problem found while attempting to play a file with the '`'
(backtick) character in it, 2/3 is a critical fix.  1/3 is a minor
preparation cleanup and 3/3 was a following cleanup for existing call
sites.

New release coming in a day or so since this is a user-visible bug
(and we might as well release with some of our new features anyways,
since I might not have time to work on more fadefx processing for
another 2-3 weeks).

[PATCH 1/3] xs: allow taking a string as input
[PATCH 2/3] escape INFILE and related environment variables
[PATCH 3/3] cleanup: avoid redundant Array conversion for escapes

 bin/dtas-cueedit                  | 4 ++--
 lib/dtas/partstats.rb             | 2 +-
 lib/dtas/player.rb                | 2 +-
 lib/dtas/player/client_handler.rb | 2 +-
 lib/dtas/process.rb               | 2 +-
 lib/dtas/source/av_ff_common.rb   | 2 +-
 lib/dtas/source/sox.rb            | 2 +-
 lib/dtas/splitfx.rb               | 8 +++++---
 lib/dtas/xs.rb                    | 2 +-
 9 files changed, 14 insertions(+), 12 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] xs: allow taking a string as input
  2015-04-13  1:04 [PATCH 0/3] filename escaping fixups Eric Wong
@ 2015-04-13  1:04 ` Eric Wong
  2015-04-13  1:04 ` [PATCH 2/3] escape INFILE and related environment variables Eric Wong
  2015-04-13  1:04 ` [PATCH 3/3] cleanup: avoid redundant Array conversion for escapes Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-04-13  1:04 UTC (permalink / raw)
  To: dtas-all

This allows us to avoid unnecessary Array conversions in
call sites
---
 lib/dtas/xs.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dtas/xs.rb b/lib/dtas/xs.rb
index 04ac252..7b3a0c2 100644
--- a/lib/dtas/xs.rb
+++ b/lib/dtas/xs.rb
@@ -9,6 +9,6 @@ require 'shellwords'
 # again, filesystems can use any byte value in names except '\0'.
 module DTAS::XS # :nodoc:
   def xs(ary)
-    Shellwords.join(ary.map(&:b))
+    Shellwords.join(Array(ary).map(&:b))
   end
 end
-- 
EW



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] escape INFILE and related environment variables
  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
  2015-04-13  1:04 ` [PATCH 3/3] cleanup: avoid redundant Array conversion for escapes Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-04-13  1:04 UTC (permalink / raw)
  To: dtas-all

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] cleanup: avoid redundant Array conversion for escapes
  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 ` [PATCH 2/3] escape INFILE and related environment variables Eric Wong
@ 2015-04-13  1:04 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2015-04-13  1:04 UTC (permalink / raw)
  To: dtas-all

We already convert xs arg to be an Array, so avoid bloating
our code with redundancy.
---
 bin/dtas-cueedit                  | 4 ++--
 lib/dtas/player.rb                | 2 +-
 lib/dtas/player/client_handler.rb | 2 +-
 lib/dtas/process.rb               | 2 +-
 lib/dtas/splitfx.rb               | 2 +-
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/bin/dtas-cueedit b/bin/dtas-cueedit
index a2056d3..603bf28 100755
--- a/bin/dtas-cueedit
+++ b/bin/dtas-cueedit
@@ -49,7 +49,7 @@ ARGV.each do |file|
     # avoid an expensive update if the user didn't change anything
     current = File.binread(tmp.path)
     if current == original
-      $stderr.puts "tags for #{xs(Array(file))} unchanged" if $DEBUG
+      $stderr.puts "tags for #{xs(file)} unchanged" if $DEBUG
       next
     end
 
@@ -65,7 +65,7 @@ ARGV.each do |file|
       warn err_msg(cmd, $?)
       warn "E: restoring original from backup"
       x!(*%W(metaflac --import-cuesheet-from=#{backup.path} #{file}))
-      warn "E: backup cuesheet restored, #{xs(Array(file))} unchanged"
+      warn "E: backup cuesheet restored, #{xs(file)} unchanged"
       exit(false)
     end
   ensure
diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb
index ea04dca..cdf1265 100644
--- a/lib/dtas/player.rb
+++ b/lib/dtas/player.rb
@@ -60,7 +60,7 @@ class DTAS::Player # :nodoc:
   end
 
   def wall(msg)
-    __wall(xs(Array(msg)))
+    __wall(xs(msg))
   end
 
   def __wall(msg)
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index a867265..b04872b 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -535,7 +535,7 @@ module DTAS::Player::ClientHandler # :nodoc:
       begin
         sf.dump(self)
       rescue => e
-        return io.emit("ERR dumping to #{xs(Array(dest))} #{e.message}")
+        return io.emit("ERR dumping to #{xs(dest)} #{e.message}")
       end
     end
     io.emit("OK")
diff --git a/lib/dtas/process.rb b/lib/dtas/process.rb
index ab4b2d5..5be107f 100644
--- a/lib/dtas/process.rb
+++ b/lib/dtas/process.rb
@@ -99,6 +99,6 @@ module DTAS::Process # :nodoc:
     _, status = Process.waitpid2(pid)
     return res if status.success?
     return status if no_raise
-    raise RuntimeError, "`#{xs(Array(cmd))}' failed: #{status.inspect}"
+    raise RuntimeError, "`#{xs(cmd)}' failed: #{status.inspect}"
   end
 end
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index fcd0028..6271fb0 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -298,7 +298,7 @@ class DTAS::SplitFX # :nodoc:
       samples = @t2s.call(stop_time)
       prev = @tracks.last and prev.commit(samples)
     else
-      raise ArgumentError, "unknown command: #{xs(Array(cmd))}"
+      raise ArgumentError, "unknown command: #{xs(cmd)}"
     end
   end
 
-- 
EW



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-04-13  1:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/3] escape INFILE and related environment variables Eric Wong
2015-04-13  1:04 ` [PATCH 3/3] cleanup: avoid redundant Array conversion for escapes Eric Wong

everything related to duct tape audio suite (dtas)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://80x24.org/dtas-all
	git clone --mirror http://ou63pmih66umazou.onion/dtas-all

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 dtas-all dtas-all/ https://80x24.org/dtas-all \
		dtas-all@nongnu.org
	public-inbox-index dtas-all

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.dtas
	nntp://ou63pmih66umazou.onion/inbox.comp.audio.dtas
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	dtas.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git