From d53361e50df09ebb57786aa44ba5f7314625ba96 Mon Sep 17 00:00:00 2001 From: flynnjustin24 Date: Sun, 8 Feb 2026 09:58:51 -0500 Subject: [PATCH] Potential fix for code scanning alert no. 10: Incomplete URL substring sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- source/conf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/conf.py b/source/conf.py index ccb828b6e..fd75673c2 100644 --- a/source/conf.py +++ b/source/conf.py @@ -4,6 +4,7 @@ import os import pathlib import sys +from urllib.parse import urlparse _ROOT = pathlib.Path(__file__).resolve().parent.parent sys.path.append(os.fspath(_ROOT)) @@ -12,9 +13,10 @@ RTD_BUILD = bool(os.getenv("READTHEDOCS")) RTD_PR_BUILD = RTD_BUILD and os.getenv("READTHEDOCS_VERSION_TYPE") == "external" RTD_URL = os.getenv("READTHEDOCS_CANONICAL_URL") -RTD_CANONICAL_BUILD = ( - RTD_BUILD and not RTD_PR_BUILD and "packaging.python.org" in RTD_URL -) +RTD_CANONICAL_BUILD = False +if RTD_BUILD and not RTD_PR_BUILD and RTD_URL: + parsed_url = urlparse(RTD_URL) + RTD_CANONICAL_BUILD = parsed_url.hostname == "packaging.python.org" project = "Python Packaging User Guide"