Skip to content

Loading…

error on upload from safari 5.1.5 #162

Closed
chrisdrackett opened this Issue · 8 comments

4 participants

@chrisdrackett

I'm getting the following when trying to upload a song:


16:14:50 web.1       | ArgumentError - string contains null byte:
16:14:50 web.1       |  /Users/calvin/play/app/api/system.rb:37:in `system'
16:14:50 web.1       |  /Users/calvin/play/app/api/system.rb:37:in `POST /upload'
16:14:50 web.1       |  /Users/calvin/play/app/api/system.rb:32:in `each'
16:14:50 web.1       |  /Users/calvin/play/app/api/system.rb:32:in `POST /upload'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:1211:in `call'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:1211:in `compile!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `[]'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:801:in `route_eval'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:785:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:822:in `process_route'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `catch'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:820:in `process_route'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:784:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in `each'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:783:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:886:in `dispatch!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in `call!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `invoke'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `catch'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `invoke'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in `call!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:705:in `call'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/warden-1.1.0/lib/warden/manager.rb:35:in `call'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/warden-1.1.0/lib/warden/manager.rb:34:in `catch'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/warden-1.1.0/lib/warden/manager.rb:34:in `call'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:766:in `forward'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:835:in `route_missing'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:796:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:792:in `route!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:886:in `dispatch!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:719:in `call!'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `invoke'
16:14:50 web.1       |  /Users/calvin/play/vendor/gems/ruby/1.8/gems/sinatra-1.3.2/lib/sinatra/base.rb:871:in `catch'
@holman
Play member

You up-to-date? This should have been fixed in a relatively recent push.

@chrisdrackett

installed this morning, but I'll update :)

EDIT: yep, up to date!

@holman
Play member

Weird; I'm not sure then. That fixed it for us when this cropped up earlier.

@jayzes

Noticed the same thing from here with 5.1.5. Haven't tried it in other browsers.

@chrisdrackett

I know for a fact it works generally well in safari 5.2. There are some bugs with the files not always starting their upload, but I attribute that to the Mountain Lion RC, not play :)

@joeyw

Does this happen for all songs?

Can you share the output of this command:

cd play
sed -n 33,37p app/api/system.rb
@jayzes

Seems to happen for all songs, yeah.

Here's the output of that see command:

    tmpfile = file[:tempfile]
    name    = file[:filename].chomp

    file_with_name = File.join("/tmp", name)
    system "mv", tmpfile.path, file_with_name
@joeyw

I was able to reproduce the bug and will be submitting a pull request. Here is a patch you can apply in the meantime.

From 5b47d043064a50fede5612f599aaf5e7fc047e5f Mon Sep 17 00:00:00 2001
From: Joey Wendt <joey@joeywendt.com>
Date: Tue, 22 May 2012 11:48:45 -0500
Subject: [PATCH] Remove null bytes from uploaded song file names. Closes 162.

---
 app/api/system.rb |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/app/api/system.rb b/app/api/system.rb
index 6d69bb2..108eec4 100644
--- a/app/api/system.rb
+++ b/app/api/system.rb
@@ -31,7 +31,7 @@ module Play
     post '/upload' do
       params[:files].each do |file|
         tmpfile = file[:tempfile]
-        name    = file[:filename].chomp
+        name    = file[:filename].chomp.delete("\000")

         file_with_name = File.join("/tmp", name)
         system "mv", tmpfile.path, file_with_name
-- 
1.7.9
@holman holman closed this in 83d0ee0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.