Skip to content

Commit a8f35bb

Browse files
dvzrvAA-Turner
andauthored
Do not use query components in URLs for assets in EPUB rendering (#11766)
Signed-off-by: David Runge <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent d69d191 commit a8f35bb

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Bugs fixed
7070
Patch by James Addison.
7171
* #11886: Print the Jinja2 template path chain in ``TemplateNotFound`` exceptions.
7272
Patch by Colin Marquardt.
73+
* #11598: Do not use query components in URLs for assets in EPUB rendering.
74+
Patch by David Runge.
7375

7476
Testing
7577
-------

sphinx/builders/html/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,8 +1051,10 @@ def css_tag(css: _CascadingStyleSheet) -> str:
10511051
for key, value in css.attributes.items()
10521052
if value is not None]
10531053
uri = pathto(os.fspath(css.filename), resource=True)
1054-
if checksum := _file_checksum(outdir, css.filename):
1055-
uri += f'?v={checksum}'
1054+
# the EPUB format does not allow the use of query components
1055+
if self.name != 'epub':
1056+
if checksum := _file_checksum(outdir, css.filename):
1057+
uri += f'?v={checksum}'
10561058
return f'<link {" ".join(sorted(attrs))} href="{uri}" />'
10571059

10581060
ctx['css_tag'] = css_tag
@@ -1079,8 +1081,10 @@ def js_tag(js: _JavaScript | str) -> str:
10791081
# https://docs.mathjax.org/en/v2.7-latest/configuration.html#considerations-for-using-combined-configuration-files
10801082
# https://github.com/sphinx-doc/sphinx/issues/11658
10811083
pass
1082-
elif checksum := _file_checksum(outdir, js.filename):
1083-
uri += f'?v={checksum}'
1084+
# the EPUB format does not allow the use of query components
1085+
elif self.name != 'epub':
1086+
if checksum := _file_checksum(outdir, js.filename):
1087+
uri += f'?v={checksum}'
10841088
if attrs:
10851089
return f'<script {" ".join(sorted(attrs))} src="{uri}"></script>'
10861090
return f'<script src="{uri}"></script>'

0 commit comments

Comments
 (0)