tags:

views:

55

answers:

3

I allow users to submit a query at mysite.com/go/QUERY\

If the query contains "/" Apache chokes.

From urls.py:

(r'^go/(?P<querytext>.*)$', 'mysite.engine.views.go'),

Try:

http://mysite.com/go/http%3A%2F%2F

Result:

Not Found

The requested URL /go/http:// was not found on this server.
Apache/2.2.12 (Ubuntu) Server at ...

BUT, if I enter the non URL quoted values it works: http://mysite.com/go/http:// WORKS just fine...

Any ideas?

+2  A: 

From the Django docs it looks like you're only supposed to use the (?P....) notation when implementing a named group (http://docs.djangoproject.com/en/1.1/topics/http/urls/#named-groups).

Try fixing your regex by either getting rid of the ?P or completing the syntax and naming the group like (?P<search-term>.*)

edub
sorry, the HTML took that out, I edited it to show what I really have in urls.py. It is as you point out.
Art
A: 

Looks like you might need to decode the URL before you pass it along. You can do this with urllib.unquote.

>>> import urllib
>>> urllib.unquote("""http%3A%2F%2F""")
'http://'
jathanism
+2  A: 

Your httpd is blocking encoded slashes.

try adding AllowEncodedSlashes On to your apache config to enable encoded slashes in apache (docs)

Ofri Raviv
Nice one! I didn't even think to look at Apache as the culprit.
jathanism