Opened 10 years ago

Closed 10 years ago

#2934 defect closed fixed (fixed)

t.web's Request.prePathURL does not rebuild the URL correctly

Reported by: emgee Owned by:
Priority: highest Milestone:
Component: web Keywords:
Cc: matt@… Branch: branches/prepath-quoting-2934
branch-diff, diff-cov, branch-cov, buildbot
Author: exarkun

Description

Quick summary is that the way Request unquotes and quotes the bits of the URL is not symmetrical. This shows up when a path segment contains a '/' for example.

Request.postpath is a list of decoded, i.e. real, path segments:

self.postpath = map(unquote, string.split(self.path[1:], '/'))

Items in Request.prepath are moved to Request.prepath as child resource are located, making prepath also a list of decoded path segments.

However, Request._prePathURL does not re-quote the individual prepath items. Instead it seems to rely on urllib.quote working (which it doesn't) for the whole URL string.

A fix can probably be taken from Nevow's flattener code. It uses the following to encode each path segment, query parameter name, query parameter value and fragment:

urllib.quote(original, safe="-_.!*'()")

Change History (6)

comment:1 Changed 10 years ago by Jean-Paul Calderone

Owner: changed from jknight to Jean-Paul Calderone
Status: newassigned

comment:2 Changed 10 years ago by Jean-Paul Calderone

author: exarkun
Branch: branches/prepath-quoting-2934

(In [22049]) Branching to 'prepath-quoting-2934'

comment:3 Changed 10 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone deleted
Status: assignednew

I fixed this by quoting each segment with safe= instead of quoting the whole URL.

This is different from what it used to do in that the hostname no longer goes through the quoting step. I don't know if this is right or not.

Ready for review.

comment:4 Changed 10 years ago by therve

Keywords: review removed
Owner: set to Jean-Paul Calderone
Priority: normalhighest

I don't think that quoting hostname is a problem. It should not contain characters that needs quoting anyway.

Please merge.

comment:5 Changed 10 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [22056]) Merge prepath-quoting-2934

Author: exarkun Reviewer: therve Fixes #2934

Correctly re-quote URL path segments when generating an URL string to return from Request.prePathURL.

comment:6 Changed 6 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.