mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
feat: add customizable brand spinners with theme integration (#34764)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Evan Rusackas <evan@preset.io>
This commit is contained in:
committed by
GitHub
parent
b7a193d53e
commit
b0d3f0f0d4
@@ -46,6 +46,8 @@ from superset.utils.core import (
|
||||
QueryObjectFilterClause,
|
||||
QuerySource,
|
||||
remove_extra_adhoc_filters,
|
||||
sanitize_svg_content,
|
||||
sanitize_url,
|
||||
)
|
||||
from tests.conftest import with_config
|
||||
|
||||
@@ -1122,3 +1124,41 @@ def test_get_stacktrace():
|
||||
except Exception:
|
||||
stacktrace = get_stacktrace()
|
||||
assert stacktrace is None
|
||||
|
||||
|
||||
def test_sanitize_svg_content_safe():
|
||||
"""Test that safe SVG content is preserved."""
|
||||
safe_svg = '<svg><rect width="10" height="10"/></svg>'
|
||||
result = sanitize_svg_content(safe_svg)
|
||||
assert "svg" in result
|
||||
assert "rect" in result
|
||||
|
||||
|
||||
def test_sanitize_svg_content_removes_scripts():
|
||||
"""Test that nh3 removes dangerous script content."""
|
||||
malicious_svg = '<svg><script>alert("xss")</script><rect/></svg>'
|
||||
result = sanitize_svg_content(malicious_svg)
|
||||
assert "script" not in result.lower()
|
||||
assert "alert" not in result
|
||||
|
||||
|
||||
def test_sanitize_url_relative():
|
||||
"""Test that relative URLs are allowed."""
|
||||
assert sanitize_url("/static/spinner.gif") == "/static/spinner.gif"
|
||||
|
||||
|
||||
def test_sanitize_url_safe_absolute():
|
||||
"""Test that safe absolute URLs are allowed."""
|
||||
assert (
|
||||
sanitize_url("https://example.com/spinner.gif")
|
||||
== "https://example.com/spinner.gif"
|
||||
)
|
||||
assert (
|
||||
sanitize_url("http://localhost/spinner.png") == "http://localhost/spinner.png"
|
||||
)
|
||||
|
||||
|
||||
def test_sanitize_url_blocks_dangerous():
|
||||
"""Test that dangerous URL schemes are blocked."""
|
||||
assert sanitize_url("javascript:alert('xss')") == ""
|
||||
assert sanitize_url("data:text/html,<script>alert(1)</script>") == ""
|
||||
|
||||
Reference in New Issue
Block a user