Raise an error when local asset files contain a `?`

This commit is contained in:
Adam Turner
2023-08-11 22:07:07 +01:00
parent 7758e01623
commit 44a7820cd9
2 changed files with 29 additions and 3 deletions
+20 -2
View File
@@ -11,8 +11,12 @@ import pytest
from html5lib import HTMLParser
import sphinx.builders.html
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
from sphinx.errors import ConfigError
from sphinx.builders.html import (
_file_checksum,
validate_html_extra_path,
validate_html_static_path,
)
from sphinx.errors import ConfigError, ThemeError
from sphinx.testing.util import strip_escseq
from sphinx.util.inventory import InventoryFile
@@ -1242,6 +1246,20 @@ def test_file_checksum(app):
assert '<script src="https://example.com/script.js"></script>' in content
def test_file_checksum_query_string():
with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'):
_file_checksum('', 'with_query_string.css?dead_parrots=1')
with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'):
_file_checksum('', 'with_query_string.js?dead_parrots=1')
with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'):
_file_checksum(Path.cwd(), '_static/with_query_string.css?dead_parrots=1')
with pytest.raises(ThemeError, match='Local asset file paths must not contain query strings'):
_file_checksum(Path.cwd(), '_static/with_query_string.js?dead_parrots=1')
@pytest.mark.sphinx('html', testroot='html_assets')
def test_javscript_loading_method(app):
app.add_js_file('normal.js')