fix: correct tojson|safe usage in templates and update validator
- Remove |safe from |tojson in HTML attributes (x-data) - quotes must become " for browsers to parse correctly - Update LANG-002 and LANG-003 architecture rules to document correct |tojson usage patterns: - HTML attributes: |tojson (no |safe) - Script blocks: |tojson|safe - Fix validator to warn when |tojson|safe is used in x-data (breaks HTML attribute parsing) - Improve code quality across services, APIs, and tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -236,7 +236,8 @@ class TestMiddlewareStackIntegration:
|
||||
@app.get("/api/test-execution-order")
|
||||
async def test_execution_order(request: Request):
|
||||
return {
|
||||
"has_vendor": hasattr(request.state, "vendor") and request.state.vendor is not None,
|
||||
"has_vendor": hasattr(request.state, "vendor")
|
||||
and request.state.vendor is not None,
|
||||
"has_clean_path": hasattr(request.state, "clean_path"),
|
||||
"has_context_type": hasattr(request.state, "context_type"),
|
||||
}
|
||||
@@ -263,7 +264,8 @@ class TestMiddlewareStackIntegration:
|
||||
@app.get("/api/test-theme-loading")
|
||||
async def test_theme_loading(request: Request):
|
||||
return {
|
||||
"has_vendor": hasattr(request.state, "vendor") and request.state.vendor is not None,
|
||||
"has_vendor": hasattr(request.state, "vendor")
|
||||
and request.state.vendor is not None,
|
||||
"has_theme": hasattr(request.state, "theme"),
|
||||
"theme_primary_color": (
|
||||
request.state.theme.get("primary_color")
|
||||
@@ -308,7 +310,8 @@ class TestMiddlewareStackIntegration:
|
||||
@app.get("/api/test-missing-vendor")
|
||||
async def test_missing_vendor(request: Request):
|
||||
return {
|
||||
"has_vendor": hasattr(request.state, "vendor") and request.state.vendor is not None,
|
||||
"has_vendor": hasattr(request.state, "vendor")
|
||||
and request.state.vendor is not None,
|
||||
"vendor": (
|
||||
request.state.vendor if hasattr(request.state, "vendor") else None
|
||||
),
|
||||
@@ -339,7 +342,8 @@ class TestMiddlewareStackIntegration:
|
||||
@app.get("/api/test-inactive-vendor")
|
||||
async def test_inactive_vendor_endpoint(request: Request):
|
||||
return {
|
||||
"has_vendor": hasattr(request.state, "vendor") and request.state.vendor is not None,
|
||||
"has_vendor": hasattr(request.state, "vendor")
|
||||
and request.state.vendor is not None,
|
||||
"vendor": (
|
||||
request.state.vendor if hasattr(request.state, "vendor") else None
|
||||
),
|
||||
@@ -349,7 +353,9 @@ class TestMiddlewareStackIntegration:
|
||||
mock_settings.platform_domain = "platform.com"
|
||||
response = client.get(
|
||||
"/api/test-inactive-vendor",
|
||||
headers={"host": f"{middleware_inactive_vendor.subdomain}.platform.com"},
|
||||
headers={
|
||||
"host": f"{middleware_inactive_vendor.subdomain}.platform.com"
|
||||
},
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user