mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-13 06:24:46 -05:00
Raise an error when local asset files contain a `?`
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user