This is an archive of the discontinued LLVM Phabricator instance.

LNT: fix broken relative redirect
ClosedPublic

Authored by tnfchris on Dec 11 2020, 5:58 AM.

Details

Reviewers
thopre
Summary

RFC 2616 had at some point an ambiguous statement in it that made it
look like relative URIs was not allowed in the Location header. This RFC is
now outdated and superseded with RFC 7231

Some implementations like Flask implemented their response object
based on this mistake. This ambiguity was later corrected in updated
RFC 7231 but Flask has kept the old implementation. Which means to get
correct standards compliant redirects we need to override the default
responder and tell it not to force absolute URIs.

Former wording of the RFC:

The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of the request or identification of a new resource. For 201 (Created) responses, the Location is that of the new resource which was created by the request. For 3xx responses, the location SHOULD indicate the server's preferred URI for automatic redirection to the resource. The field value consists of a single absolute URI.

Location       = "Location" ":" absoluteURI

Current wording

The "Location" header field is used in some responses to refer to a
specific resource in relation to the response.  The type of
relationship is defined by the combination of request method and
status code semantics.

  Location = URI-reference

[1] https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
[2] https://tools.ietf.org/html/rfc7231#section-7.1.2

Diff Detail

Event Timeline

tnfchris requested review of this revision.Dec 11 2020, 5:58 AM
tnfchris created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 11 2020, 5:58 AM

In the description:

has at some point -> had at some point

Would you happen to know the former wording? If not don't bother searching but if yes maybe you could quote it in the description

lnt/server/ui/globals.py
45

I don't quite understand this line but how about:

adhering to a typo the out-dated -> a misunderstanding of an ambiguous statement in a former version of RFC 2616

47

by -> but
doesn't -> does not

tnfchris edited the summary of this revision. (Show Details)Dec 11 2020, 6:41 AM
tnfchris edited the summary of this revision. (Show Details)Dec 11 2020, 8:05 AM
tnfchris edited the summary of this revision. (Show Details)Dec 11 2020, 8:14 AM
tnfchris updated this revision to Diff 311232.Dec 11 2020, 8:32 AM

Updated comment

thopre accepted this revision.Dec 11 2020, 8:34 AM

LGTM with the contraction fix (doesn't -> does not)

lnt/server/ui/globals.py
48

doesn't -> does not

This revision is now accepted and ready to land.Dec 11 2020, 8:34 AM
tnfchris updated this revision to Diff 311244.Dec 11 2020, 9:02 AM
thopre accepted this revision.Dec 11 2020, 10:17 AM
tnfchris closed this revision.Dec 13 2020, 6:19 AM