Skip to content

Commit 1a2fa15

Browse files
authored
Return 404 for missing release slashes (boostorg#1929) (boostorg#1932)
1 parent cb5c4ab commit 1a2fa15

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SourceDocType(Enum):
88

99

1010
SLACK_URL = "https://cpplang.slack.com"
11+
STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES = ("releases/",)
1112
# possible library versions are: boost_1_53_0_beta1, 1_82_0, 1_55_0b1
1213
BOOST_LIB_PATH_RE = re.compile(r"^(boost_){0,1}([0-9_]*[0-9]+[^/]*)/(.*)")
1314
NO_PROCESS_LIBS = [

core/views.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
get_meta_redirect_from_html,
4444
get_s3_client,
4545
)
46-
from .constants import SourceDocType, BOOST_LIB_PATH_RE
46+
from .constants import (
47+
SourceDocType,
48+
BOOST_LIB_PATH_RE,
49+
STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES,
50+
)
4751
from .htmlhelper import (
4852
modernize_legacy_page,
4953
convert_name_to_id,
@@ -249,6 +253,13 @@ def get(self, request, *args, **kwargs):
249253
See the *_static_config.json files for URL mappings to specific S3 keys.
250254
"""
251255
content_path = self.kwargs.get("content_path")
256+
257+
# Exit early for paths we know we don't want to handle here. We know that these
258+
# paths should have been resolved earlier by the URL router, and if we return
259+
# a 404 here redirecting will be handled by the webserver configuration.
260+
if content_path.startswith(STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES):
261+
raise Http404("Content not found")
262+
252263
updated_legacy_path = legacy_path_transform(content_path)
253264
if updated_legacy_path != content_path:
254265
return redirect(

0 commit comments

Comments
 (0)