Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion python_a2a/server/http.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
"""
HTTP server implementation for the A2A protocol.
"""
Expand Down Expand Up @@ -108,10 +109,14 @@ def enhanced_a2a_index():
})

# Otherwise serve HTML by default
# Validate host_url to prevent Host-header injection
host_url = request.host_url
if not re.match(r'^https?://[a-zA-Z0-9._-]+(:\d+)?/', host_url):
host_url = request.scheme + "://" + request.host.split(":")[0]
response = make_response(render_template_string(
AGENT_INDEX_HTML,
agent=agent,
request=request
host_url=host_url
))
response.headers['Content-Type'] = 'text/html; charset=utf-8'
return response
Expand Down