Update backend/app/api/skills_marketplace.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Hugh Brown
2026-03-03 16:55:55 -07:00
committed by Abhimanyu Saharan
parent cd70242043
commit cd7e411b3e

View File

@@ -687,7 +687,12 @@ def _sanitize_field(value: str) -> str:
Prevents prompt injection via skill name or URL fields that could Prevents prompt injection via skill name or URL fields that could
break out of the structured data section into the instruction section. break out of the structured data section into the instruction section.
""" """
return value.replace("\n", " ").replace("\r", " ").strip() sanitized = "".join(
ch if ch.isprintable() and ch not in {"\n", "\r"} else " " for ch in value
)
# Normalize any runs of whitespace (including tabs) down to single spaces.
sanitized = re.sub(r"\s+", " ", sanitized)
return sanitized.strip()
def _install_instruction(*, skill: MarketplaceSkill, gateway: Gateway) -> str: def _install_instruction(*, skill: MarketplaceSkill, gateway: Gateway) -> str: