diff --git a/superset/mcp_service/chart/schemas.py b/superset/mcp_service/chart/schemas.py
index 6b5ed699672..d02f3c7de02 100644
--- a/superset/mcp_service/chart/schemas.py
+++ b/superset/mcp_service/chart/schemas.py
@@ -21,8 +21,6 @@ Pydantic schemas for chart-related responses
from __future__ import annotations
-import html
-import re
from datetime import datetime, timezone
from typing import Annotated, Any, Dict, List, Literal, Protocol
@@ -50,6 +48,10 @@ from superset.mcp_service.system.schemas import (
TagInfo,
UserInfo,
)
+from superset.mcp_service.utils.sanitization import (
+ sanitize_filter_value,
+ sanitize_user_input,
+)
class ChartLike(Protocol):
@@ -357,113 +359,17 @@ class ColumnRef(BaseModel):
@classmethod
def sanitize_name(cls, v: str) -> str:
"""Sanitize column name to prevent XSS and SQL injection."""
- if not v or not v.strip():
- raise ValueError("Column name cannot be empty")
-
- # Length check first to prevent ReDoS attacks
- if len(v) > 255:
- raise ValueError(
- f"Column name too long ({len(v)} characters). "
- f"Maximum allowed length is 255 characters."
- )
-
- # Remove HTML tags and decode entities
- sanitized = html.escape(v.strip())
-
- # Check for dangerous HTML tags using substring checks (safe)
- dangerous_tags = ["",
- "