Allow for direct URLs to abbreviated legacy PostgreSQL releases

For example, while a link to "/docs/release/9.1.0/" would work,
going to "/docs/release/9.1/" would not; in this case, it would
show the release details for "9.0.1". While the probability of
someone modifying the links to see the different release notes
is low, we would still need to take action on what is an
incorrect link.

Instead of returning a 404, this transposes the major/minor
version to point at the canonical version number and render the
expected page. This is set up to work for the 6, 7, 8, 9 series.

Reported by: Nikolay Samokhvalov <samokhvalov@gmail.com>
This commit is contained in:
Jonathan S. Katz
2020-10-12 14:00:09 -04:00
parent 311a6b28d3
commit f923e09535

View File

@ -268,6 +268,16 @@ def release_notes(request, major_version=None, minor_version=None):
# notes
# otherwise ensure the release notes are returned in order
if major_version is not None and minor_version is not None:
# a quick check to see if major is one of 6 - 9 as a whole number. If
# it is, this may be because someone is trying to up a major version
# directly from the URL, e.g. "9.1", even through officially the release
# number was "9.1.0".
# anyway, we shouldn't 404, but instead transpose from "9.1" to "9.1.0".
# if it's not an actual PostgreSQL release (e.g. "9.9"), then it will
# 404 at a later step.
if major_version in ['6', '7', '8', '9']:
major_version = "{}.{}".format(major_version, minor_version)
minor_version = '0'
# at this point, include the content
sql = sql.format(content="content,")
# restrict to the major version, order from latest to earliest minor