|
From: <mi...@us...> - 2026-08-21 08:27:57
|
Revision: 10394
http://sourceforge.net/p/docutils/code/10394
Author: milde
Date: 2026-08-21 08:27:55 +0000 (Fri, 21 Aug 2026)
Log Message:
-----------
Avoid unescaped special characters in PEP HTML output.
Do not use a "raw" html node to mask author email address in PEP transforms.
The email masking is now a bit less obscuring but this should be OK for
local previews (the official PEPs are produced with a different toolchain).
Escape special HTML characters in HTML header generated from index metadata.
Fixes [bugs:#519].
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/transforms/peps.py
trunk/docutils/docutils/writers/pep_html/__init__.py
trunk/docutils/test/functional/expected/pep_html.html
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2026-08-21 08:27:15 UTC (rev 10393)
+++ trunk/docutils/HISTORY.rst 2026-08-21 08:27:55 UTC (rev 10394)
@@ -113,6 +113,10 @@
- Clear "ids" and "names" in `ContentsFilter` so ids and names stay
unique when copying section title content for the ToC entry.
+* docutils/transforms/peps.py:
+
+ - Don't use raw HTML for masked email addresses.
+
* docutils/transforms/references.py
- `IndirectHyperlinks.resolve_indirect_target()` no longer calls
@@ -173,6 +177,7 @@
`.Writer.assemble_parts()` from `list` to `str`.
(`The Docutils Publisher` says: "all parts returned
by the HTML writers are of data type str.")
+ - HTML-escape `interpolation_dict` values extracted from the index.
Release 0.23 (2026-05-27)
Modified: trunk/docutils/docutils/transforms/peps.py
===================================================================
--- trunk/docutils/docutils/transforms/peps.py 2026-08-21 08:27:15 UTC (rev 10393)
+++ trunk/docutils/docutils/transforms/peps.py 2026-08-21 08:27:55 UTC (rev 10394)
@@ -319,8 +319,8 @@
if ref['refuri'][8:] in non_masked_addresses:
replacement = ref[0]
else:
- replacement_text = ref.astext().replace('@', ' at ')
- replacement = nodes.raw('', replacement_text, format='html')
+ replacement_text = ref.astext().replace('@', ' at ')
+ replacement = nodes.Text(replacement_text)
if pepno is None:
return replacement
else:
Modified: trunk/docutils/docutils/writers/pep_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/pep_html/__init__.py 2026-08-21 08:27:15 UTC (rev 10393)
+++ trunk/docutils/docutils/writers/pep_html/__init__.py 2026-08-21 08:27:55 UTC (rev 10394)
@@ -10,6 +10,7 @@
__docformat__ = 'reStructuredText'
+import html
import os
import os.path
@@ -66,12 +67,12 @@
index = self.document.first_child_matching_class(nodes.field_list)
header = self.document[index]
self.pepnum = header[0][1].astext()
- subs['pep'] = self.pepnum
+ subs['pep'] = html.escape(self.pepnum)
try:
subs['pepnum'] = '%04i' % int(self.pepnum)
except ValueError:
subs['pepnum'] = self.pepnum
- self.title = header[1][1].astext()
+ self.title = html.escape(header[1][1].astext())
subs['title'] = self.title
subs['body'] = ''.join(
self.body_pre_docinfo + self.docinfo + self.body)
Modified: trunk/docutils/test/functional/expected/pep_html.html
===================================================================
--- trunk/docutils/test/functional/expected/pep_html.html 2026-08-21 08:27:15 UTC (rev 10393)
+++ trunk/docutils/test/functional/expected/pep_html.html 2026-08-21 08:27:55 UTC (rev 10394)
@@ -33,9 +33,9 @@
</tr>
<tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference external" href="http://hg.python.org/peps/file/default/pep-0100.txt">A long time ago.</a></td>
</tr>
-<tr class="field"><th class="field-name">Author:</th><td class="field-body">John Doe <john at example.org></td>
+<tr class="field"><th class="field-name">Author:</th><td class="field-body">John Doe <john at example.org></td>
</tr>
-<tr class="field"><th class="field-name">Discussions-To:</th><td class="field-body"><<a class="reference external" href="mailto:devnull%40example.org?subject=PEP%20100">devnull at example.org</a>></td>
+<tr class="field"><th class="field-name">Discussions-To:</th><td class="field-body"><<a class="reference external" href="mailto:devnull%40example.org?subject=PEP%20100">devnull at example<span>.</span>org</a>></td>
</tr>
<tr class="field"><th class="field-name">Status:</th><td class="field-body">Draft</td>
</tr>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|