Pylons / Pylons/webob

Allow relative URI in redirection

Open
#414 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature sprintable
Dominant language
Python
Stars
443
Forks
206
PR merge metrics
No merged PRs in 30d

Description

RFC 7231 allows for relative URI in the redirection response: https://tools.ietf.org/html/rfc7231#section-7.1.2

However, WebOb converts relative URI to absolute before sending the response. It is done when using HTTPFound, HTTPMovedPermanently exceptions or when using Response with Location header.

Here are pieces of code which demonstrate that. This code is not using any web server. It is pure Python WSGI reference implementation

from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server

from webob import Response

def app(environ, start_response):
    headers = [('Location', './new_page')]
    r = Response("redirected", status=301, headers=headers)
    return r(environ, start_response)

httpd = make_server('', 8000, app)
httpd.serve_forever()
from wsgiref.util import setup_testing_defaults
from wsgiref.simple_server import make_server

from webob.exc import HTTPMovedPermanently

def app(environ, start_response):
    r = HTTPMovedPermanently(location='./new_page')
    return r(environ, start_response)

httpd = make_server('', 8000, app)
httpd.serve_forever()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Response handling for a Location header and the HTTPMovedPermanently exception, using the two WSGI examples as reproduction cases. Trace where a relative './new_page' is converted before the response is sent. Done means relative redirect URIs remain relative in both cases, while absolute URIs continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.