From d0163941b294e203e5803724f56726e8843738c0 Mon Sep 17 00:00:00 2001
From: Varun Chawla <34209028+veeceey@users.noreply.github.com>
Date: Fri, 6 Feb 2026 23:21:00 -0800
Subject: [PATCH] fix(proxy): add regression tests for #20441 - ",
+ },
+ {
+ "role": "user",
+ "content": "",
+ },
+ {
+ "role": "user",
+ "content": "Can you explain what ",
+ },
+ {
+ "role": "user",
+ "content": "",
+ },
+ {
+ "role": "user",
+ "content": "",
+ },
+ ]
+
+ for msg in test_messages:
+ test_payload = {
+ "model": "gpt-4o",
+ "messages": [
+ {"role": "user", "content": "hi"},
+ {"role": "assistant", "content": "Hello! How can I help?"},
+ msg,
+ ],
+ }
+
+ mock_request = MagicMock()
+ mock_request.body = AsyncMock(return_value=orjson.dumps(test_payload))
+ mock_request.headers = {"content-type": "application/json"}
+ mock_request.scope = {}
+
+ result = await _read_request_body(mock_request)
+
+ assert result["model"] == "gpt-4o"
+ assert len(result["messages"]) == 3
+ assert result["messages"][2]["content"] == msg["content"], (
+ f"Message content with HTML was modified during parsing: "
+ f"expected={msg['content']!r}, got={result['messages'][2]['content']!r}"
+ )
diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py
index be8c84a554f..2cb0244f352 100644
--- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py
+++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/content_filter/test_content_filter.py
@@ -920,3 +920,148 @@ class TestContentFilterGuardrail:
assert (
"matched_text" not in detection
), "Sensitive content should not be logged"
+
+ @pytest.mark.asyncio
+ async def test_html_tags_in_messages_not_blocked(self):
+ """
+ Test that HTML tags like ",
+ "",
+ "Can you explain what ",
+ "
",
+ "",
+ "The ",
+ "