0

I've recently renamed some pages on my (sinatra-backed) site. I'm redirecting from the old names to new using the following routes, which I've put before any others:

##
# Renamed pages
#
get '/venue' do redirect '/the+wedding/reception'; end
get '/accommodation' do redirect '/out+of+town+info/accommodation'; end
get '/things+to+do' do redirect '/out+of+town+info/things+to+do'; end

The first two work fine, but the third results in a 404. Is there something special about the + in this third route? I can't find anything helpful in the documentation and I can't seem to escape them in a way that makes the route work.

I've been testing with curl, and the first two use 304s as expected, the third displays the normal 404 page.

I'm using sinatra 1.2.6 as packaged in Debian.

Edd Steel
  • 719
  • 4
  • 16
  • Which exact version of Sinatra are you using? – Holger Just Jan 02 '12 at 22:06
  • Thanks Holger, I've updated the question: 1.2.6. I'll give the gem a try and update. – Edd Steel Jan 03 '12 at 01:17
  • Works as expected on 1.3.2. I'll switch to the gem on my server (and check the bugs next time). Thanks. – Edd Steel Jan 03 '12 at 01:35
  • 1
    :) I had a similar error once which lead to bugging Konstantin who thankfully fixed it in 1.3.0 :) For future reference, it was fixed in https://github.com/sinatra/sinatra/pull/271 – Holger Just Jan 03 '12 at 10:17
  • FYI, "+" is the URL encoded representation of a space character. Is this really what you want to be using? – hmans Jan 06 '12 at 17:41
  • 1
    @hmans, it's what a space is encoded as in a form submission, but not how its encoded in the path of a URL (that would be %20 - see http://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20). It's explicitly supported, unescaped in URLs, and a deliberate choice. – Edd Steel Jan 06 '12 at 18:41
  • @HolgerJust, please feel free to repeat that in an answer so this question is no longer 'unanswered'. – Edd Steel Jan 18 '12 at 02:21

1 Answers1

2

This issue was caused by a quirk in Sinatra's request parsing. It was fixed in Sinatra 1.3.0 by Konstantin Haase with https://github.com/sinatra/sinatra/pull/271.

So once you update your Sinatra to something >= 1.3.0, request parsing should work as expected.

Holger Just
  • 52,918
  • 14
  • 115
  • 123