Repository: basecamp/pow

Issue #268: Pow can't display error pages where the code snippet has a non-US-ASCII character
Created: 2012-03-08T17:09:34Z
Pow can't display backtrace information if any code snippet in the backtrace is outside of the US-ASCII range.
# encoding: utf-8
require 'sinatra'

class TestApp < Sinatra::Base
  get '/' do
    raise "foo"
    "¢"
  end
end

Rather than a backtrace pointing to the raise line, the error displayed is:
Error starting application
Your Rack app raised an exception when Pow tried to run it.
ArgumentError: invalid byte sequence in US-ASCII
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/utils.rb:182:in `gsub'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/utils.rb:182:in `escape_html'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/showexceptions.rb:94:in `h'
(erb):184:in `block (2 levels) in pretty'
(erb):183:in `each'
(erb):183:in `block in pretty'
(erb):155:in `each'
(erb):155:in `pretty'
~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `eval'
~/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `result'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/rack-1.4.1/lib/rack/showexceptions.rb:88:in `pretty'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:30:in `rescue in call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb:21:in `call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `block in call'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1416:in `synchronize'
~/.rvm/gems/ruby-1.9.2-p290@sinatra/gems/sinatra-1.3.2/lib/sinatra/base.rb:1334:in `call'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:146:in `handle'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:99:in `rescue in block (2 levels) in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:96:in `block (2 levels) in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:86:in `each'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:86:in `block in start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:66:in `loop'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:66:in `start'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/lib/nack/server.rb:13:in `run'
~/Library/Application Support/Pow/Versions/0.3.2/node_modules/nack/bin/nack_worker:4:in `<main>'

I've created a minimal test case as a gist demonstrating this behaviour.

Duplicate issue #315: "JSON::ParserError: 743: unexpected token" with UTF-8 in cookie
Created: 2012-08-08T07:29:04Z
For a site with Google Analytics, this request works fine:
http://example.dev/?utm_medium=x&utm_source=y&utm_campaign=S%C3%A4lj
"S%C3%A4lj" is "Sälj" in UTF-8 and then URL encoded.
But on the next request to that domain, I get the Pow error "JSON::ParserError: 743: unexpected token", which I'm guessing is about this cookie shown in the error output:
__utmz=1234.5678.1.1.utmcsr=y|utmccn=S��lj|utmcmd=x"

It's easy to confirm in Chrome incognito mode. Visit the bad URL, note that the next request fails. Close and re-enter incognito mode, do the same thing but with "Salj" instead of "S%C3%A4lj" and things work fine.
If I do the same thing with "rails server" (Thin), I can't reproduce the error.

Closing comment (2013-01-30T14:06:30Z): I wonder if this is related to #268. Probably not.