From 2112cfa60946e2f78063847dd254563dcb9ecc72 Mon Sep 17 00:00:00 2001
From: sid sri
Date: Mon, 31 Aug 2026 02:14:59 +0530
Subject: [PATCH 1/3] Use canonical rfc-editor.org URL for the :rfc: role
(#14659)
Change the default rfc_base_url to https://www.rfc-editor.org/rfc/ so
that RFC references link to the canonical location where RFCs are
officially published, instead of datatracker.ietf.org.
---
CHANGES.rst | 4 ++++
sphinx/environment/__init__.py | 2 +-
tests/test_builders/test_build_html_5_output.py | 4 ++--
tests/test_markup/test_markup.py | 8 ++++----
4 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index ad6d698341a..6b38902e419 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,6 +4,10 @@ Release 9.1.1 (in development)
Bugs fixed
----------
+* #14659: Use the canonical ``https://www.rfc-editor.org/rfc/`` base URL for
+ the :rst:role:`rfc` role, instead of
+ ``https://datatracker.ietf.org/doc/html/``.
+
* #14465: LaTeX: PDF build crash since LaTeX June 2026 release if tables are
styled with ``'colorrows'`` (which is the default).
Patch by Jean-François B.
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index c5cc77139f7..8e0d6a31a75 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -63,7 +63,7 @@
'cloak_email_addresses': True,
'pep_base_url': 'https://peps.python.org/',
'pep_references': None,
- 'rfc_base_url': 'https://datatracker.ietf.org/doc/html/',
+ 'rfc_base_url': 'https://www.rfc-editor.org/rfc/',
'rfc_references': None,
'input_encoding': 'utf-8-sig',
'doctitle_xform': False,
diff --git a/tests/test_builders/test_build_html_5_output.py b/tests/test_builders/test_build_html_5_output.py
index b712d1415a3..d00fd063474 100644
--- a/tests/test_builders/test_build_html_5_output.py
+++ b/tests/test_builders/test_build_html_5_output.py
@@ -147,13 +147,13 @@ def checker(nodes: Iterable[Element]) -> Literal[True]:
),
(
'markup.html',
- ".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"
+ ".//a[@href='https://www.rfc-editor.org/rfc/rfc1.html']"
"[@class='rfc reference external']/strong",
'RFC 1',
),
(
'markup.html',
- ".//a[@href='https://datatracker.ietf.org/doc/html/rfc1.html']"
+ ".//a[@href='https://www.rfc-editor.org/rfc/rfc1.html']"
"[@class='rfc reference external']/strong",
'Request for Comments #1',
),
diff --git a/tests/test_markup/test_markup.py b/tests/test_markup/test_markup.py
index 4889ed6daa8..2d32c584c45 100644
--- a/tests/test_markup/test_markup.py
+++ b/tests/test_markup/test_markup.py
@@ -212,12 +212,12 @@ def rst_to_latex(rst: str, *, app: SphinxTestApp) -> str:
':rfc:`2324`',
(
'RFC 2324
'
+ 'href="https://www.rfc-editor.org/rfc/rfc2324.html">RFC 2324
'
),
(
'\\sphinxAtStartPar\n'
'\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}'
- '\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html}'
+ '\\sphinxhref{https://www.rfc-editor.org/rfc/rfc2324.html}'
'{\\sphinxstylestrong{RFC 2324}}'
),
),
@@ -226,13 +226,13 @@ def rst_to_latex(rst: str, *, app: SphinxTestApp) -> str:
':rfc:`2324#section-1`',
(
''
+ 'href="https://www.rfc-editor.org/rfc/rfc2324.html#section-1">'
'RFC 2324 Section 1
'
),
(
'\\sphinxAtStartPar\n'
'\\index{RFC@\\spxentry{RFC}!RFC 2324 Section 1@\\spxentry{RFC 2324 Section 1}}'
- '\\sphinxhref{https://datatracker.ietf.org/doc/html/rfc2324.html\\#section-1}'
+ '\\sphinxhref{https://www.rfc-editor.org/rfc/rfc2324.html\\#section-1}'
'{\\sphinxstylestrong{RFC 2324 Section 1}}'
),
),
From 6cc81c70db071f7406c3a3b357af6932c62239bd Mon Sep 17 00:00:00 2001
From: sid sri
Date: Mon, 31 Aug 2026 02:15:48 +0530
Subject: [PATCH 2/3] Add Sidharth Sridhar to AUTHORS.rst
---
AUTHORS.rst | 1 +
1 file changed, 1 insertion(+)
diff --git a/AUTHORS.rst b/AUTHORS.rst
index b702c64c0f9..875d75a6b04 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -106,6 +106,7 @@ Contributors
* Rui Pinheiro -- Python 3.14 forward references support
* Roland Meister -- epub builder
* Sebastian Wiesner -- image handling, distutils support
+* Sidharth Sridhar -- RFC canonical URL fix
* Slawek Figiel -- additional warning suppression
* Stefan Seefeld -- toctree improvements
* Stefan van der Walt -- autosummary extension
From 9d634abcfceb8b96e2a42f654b4fb06dd7999456 Mon Sep 17 00:00:00 2001
From: sid sri
Date: Tue, 1 Sep 2026 01:04:23 +0530
Subject: [PATCH 3/3] Use canonical /info/ URL for the :rfc: role per review
Point rfc_base_url at https://www.rfc-editor.org/info/ and build
rfcN/ links (no .html suffix, trailing slash) instead of relying on
docutils' rfc%d.html format, matching the canonical rfc-editor.org
location noted in review.
Co-Authored-By: Claude Sonnet 4.6
---
CHANGES.rst | 2 +-
sphinx/environment/__init__.py | 2 +-
sphinx/roles.py | 4 ++--
tests/test_builders/test_build_html_5_output.py | 4 ++--
tests/test_markup/test_markup.py | 8 ++++----
5 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 6b38902e419..5d5ea10a85a 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -4,7 +4,7 @@ Release 9.1.1 (in development)
Bugs fixed
----------
-* #14659: Use the canonical ``https://www.rfc-editor.org/rfc/`` base URL for
+* #14659: Use the canonical ``https://www.rfc-editor.org/info/`` base URL for
the :rst:role:`rfc` role, instead of
``https://datatracker.ietf.org/doc/html/``.
diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py
index 8e0d6a31a75..4e8b19f52ff 100644
--- a/sphinx/environment/__init__.py
+++ b/sphinx/environment/__init__.py
@@ -63,7 +63,7 @@
'cloak_email_addresses': True,
'pep_base_url': 'https://peps.python.org/',
'pep_references': None,
- 'rfc_base_url': 'https://www.rfc-editor.org/rfc/',
+ 'rfc_base_url': 'https://www.rfc-editor.org/info/',
'rfc_references': None,
'input_encoding': 'utf-8-sig',
'doctitle_xform': False,
diff --git a/sphinx/roles.py b/sphinx/roles.py
index fdb997314fe..005628b2f70 100644
--- a/sphinx/roles.py
+++ b/sphinx/roles.py
@@ -362,9 +362,9 @@ def build_uri(self) -> str:
base_url = self.inliner.document.settings.rfc_base_url
ret = self.target.partition('#')
if ret[1]:
- return base_url + self.inliner.rfc_url % int(ret[0]) + '#' + ret[2]
+ return base_url + 'rfc%d/#%s' % (int(ret[0]), ret[2])
else:
- return base_url + self.inliner.rfc_url % int(ret[0])
+ return base_url + 'rfc%d/' % int(ret[0])
def _format_rfc_target(target: str, /) -> str:
diff --git a/tests/test_builders/test_build_html_5_output.py b/tests/test_builders/test_build_html_5_output.py
index d00fd063474..8fb4378bf52 100644
--- a/tests/test_builders/test_build_html_5_output.py
+++ b/tests/test_builders/test_build_html_5_output.py
@@ -147,13 +147,13 @@ def checker(nodes: Iterable[Element]) -> Literal[True]:
),
(
'markup.html',
- ".//a[@href='https://www.rfc-editor.org/rfc/rfc1.html']"
+ ".//a[@href='https://www.rfc-editor.org/info/rfc1/']"
"[@class='rfc reference external']/strong",
'RFC 1',
),
(
'markup.html',
- ".//a[@href='https://www.rfc-editor.org/rfc/rfc1.html']"
+ ".//a[@href='https://www.rfc-editor.org/info/rfc1/']"
"[@class='rfc reference external']/strong",
'Request for Comments #1',
),
diff --git a/tests/test_markup/test_markup.py b/tests/test_markup/test_markup.py
index 2d32c584c45..30c07d989a0 100644
--- a/tests/test_markup/test_markup.py
+++ b/tests/test_markup/test_markup.py
@@ -212,12 +212,12 @@ def rst_to_latex(rst: str, *, app: SphinxTestApp) -> str:
':rfc:`2324`',
(
'RFC 2324
'
+ 'href="https://www.rfc-editor.org/info/rfc2324/">RFC 2324'
),
(
'\\sphinxAtStartPar\n'
'\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}'
- '\\sphinxhref{https://www.rfc-editor.org/rfc/rfc2324.html}'
+ '\\sphinxhref{https://www.rfc-editor.org/info/rfc2324/}'
'{\\sphinxstylestrong{RFC 2324}}'
),
),
@@ -226,13 +226,13 @@ def rst_to_latex(rst: str, *, app: SphinxTestApp) -> str:
':rfc:`2324#section-1`',
(
''
+ 'href="https://www.rfc-editor.org/info/rfc2324/#section-1">'
'RFC 2324 Section 1
'
),
(
'\\sphinxAtStartPar\n'
'\\index{RFC@\\spxentry{RFC}!RFC 2324 Section 1@\\spxentry{RFC 2324 Section 1}}'
- '\\sphinxhref{https://www.rfc-editor.org/rfc/rfc2324.html\\#section-1}'
+ '\\sphinxhref{https://www.rfc-editor.org/info/rfc2324/\\#section-1}'
'{\\sphinxstylestrong{RFC 2324 Section 1}}'
),
),