summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2012-05-25 16:52:57 -0400
committerPaul Arthur <paul.arthur@flowerysong.com>2012-05-25 16:52:57 -0400
commit408e71344ade84685c181cd326e2ec5e79c9157b (patch)
tree6385b022dd3a580baacff2d24a5ee3257bb486f2 /lib
parent09949bb20b369a662642222e3415b9de18b98f30 (diff)
downloadampache-408e71344ade84685c181cd326e2ec5e79c9157b.tar.gz
ampache-408e71344ade84685c181cd326e2ec5e79c9157b.tar.bz2
ampache-408e71344ade84685c181cd326e2ec5e79c9157b.zip
escapeshellarg's behaviour is locale-dependent
Reimplement it locally so it isn't. Might fix FS#252.
Diffstat (limited to 'lib')
-rw-r--r--lib/class/stream.class.php2
-rw-r--r--lib/general.lib.php14
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/class/stream.class.php b/lib/class/stream.class.php
index bc23d28b..4d7b44c5 100644
--- a/lib/class/stream.class.php
+++ b/lib/class/stream.class.php
@@ -691,7 +691,7 @@ class Stream {
$eofss = floor($song->time - ($eofmm * 60));
$eof = sprintf('%02d.%02d', $eofmm, $eofss);
- $song_file = escapeshellarg($song->file);
+ $song_file = scrub_arg($song->file);
$transcode_command = $song->stream_cmd();
if ($transcode_command == null) {
diff --git a/lib/general.lib.php b/lib/general.lib.php
index a8e4e909..fb7ab1a4 100644
--- a/lib/general.lib.php
+++ b/lib/general.lib.php
@@ -117,6 +117,20 @@ function unhtmlentities($string) {
} //unhtmlentities
/**
+ * scrub_arg
+ *
+ * This function behaves like escapeshellarg, but isn't broken
+ */
+function scrub_arg($arg)
+{
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
+ return '"' . str_replace(array('"', '%'), array('', ''), $arg) . '"';
+ } else {
+ return "'" . str_replace("'", "'\\''", $arg) . "'";
+ }
+}
+
+/**
* format_bytes
* Turns a size in bytes into a human-readable value
*/