summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-03-16 01:33:27 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-03-17 01:24:03 +0900
commit3937ea816ffcf381d3af0356f58083639f69e0f7 (patch)
treef78c13b257d42cdf3563172e35210c13a200cef1
parentd79d041f4f90818e0b495523fdcc28db12783caf (diff)
downloadsphinx-git-3937ea816ffcf381d3af0356f58083639f69e0f7.tar.gz
Fix #9009: LaTeX: "release" value with underscore leads to invalid LaTeX
The "release" variable is not escaped on the LaTeX output.
-rw-r--r--CHANGES1
-rw-r--r--sphinx/templates/latex/latex.tex_t2
-rw-r--r--tests/test_build_latex.py4
3 files changed, 4 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index f449442bb..5ccb86c98 100644
--- a/CHANGES
+++ b/CHANGES
@@ -107,6 +107,7 @@ Bugs fixed
* #8980: LaTeX: missing line break in ``\pysigline``
* #8995: LaTeX: legacy ``\pysiglinewithargsret`` does not compute correctly
available horizontal space and should use a ragged right style
+* #9009: LaTeX: "release" value with underscore leads to invalid LaTeX
* #8911: C++: remove the longest matching prefix in
:confval:`cpp_index_common_prefix` instead of the first that matches.
* C, properly reject function declarations when a keyword is used
diff --git a/sphinx/templates/latex/latex.tex_t b/sphinx/templates/latex/latex.tex_t
index 43ad04b0e..a9fba98d0 100644
--- a/sphinx/templates/latex/latex.tex_t
+++ b/sphinx/templates/latex/latex.tex_t
@@ -71,7 +71,7 @@
\title{<%= title %>}
\date{<%= date %>}
-\release{<%= release %>}
+\release{<%= release | e %>}
\author{<%= author %>}
<%- if logofilename %>
\newcommand{\sphinxlogo}{\sphinxincludegraphics{<%= logofilename %>}\par}
diff --git a/tests/test_build_latex.py b/tests/test_build_latex.py
index c8c94b44b..bb1904d2c 100644
--- a/tests/test_build_latex.py
+++ b/tests/test_build_latex.py
@@ -277,14 +277,14 @@ def test_latex_title_after_admonitions(app, status, warning):
@pytest.mark.sphinx('latex', testroot='basic',
- confoverrides={'release': '1.0'})
+ confoverrides={'release': '1.0_0'})
def test_latex_release(app, status, warning):
app.builder.build_all()
result = (app.outdir / 'test.tex').read_text()
print(result)
print(status.getvalue())
print(warning.getvalue())
- assert r'\release{1.0}' in result
+ assert r'\release{1.0\_0}' in result
assert r'\renewcommand{\releasename}{Release}' in result