Return 404 for missing release slashes (#1929) (#1932)

This commit is contained in:
daveoconnor
2025-09-30 14:36:43 -07:00
committed by GitHub
parent cb5c4ab492
commit 1a2fa155ee
2 changed files with 13 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ class SourceDocType(Enum):
SLACK_URL = "https://cpplang.slack.com"
STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES = ("releases/",)
# possible library versions are: boost_1_53_0_beta1, 1_82_0, 1_55_0b1
BOOST_LIB_PATH_RE = re.compile(r"^(boost_){0,1}([0-9_]*[0-9]+[^/]*)/(.*)")
NO_PROCESS_LIBS = [

View File

@@ -43,7 +43,11 @@ from .boostrenderer import (
get_meta_redirect_from_html,
get_s3_client,
)
from .constants import SourceDocType, BOOST_LIB_PATH_RE
from .constants import (
SourceDocType,
BOOST_LIB_PATH_RE,
STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES,
)
from .htmlhelper import (
modernize_legacy_page,
convert_name_to_id,
@@ -249,6 +253,13 @@ class BaseStaticContentTemplateView(TemplateView):
See the *_static_config.json files for URL mappings to specific S3 keys.
"""
content_path = self.kwargs.get("content_path")
# Exit early for paths we know we don't want to handle here. We know that these
# paths should have been resolved earlier by the URL router, and if we return
# a 404 here redirecting will be handled by the webserver configuration.
if content_path.startswith(STATIC_CONTENT_EARLY_EXIT_PATH_PREFIXES):
raise Http404("Content not found")
updated_legacy_path = legacy_path_transform(content_path)
if updated_legacy_path != content_path:
return redirect(