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
8 changes: 6 additions & 2 deletions qwen_agent/gui/gradio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import base64
import html


def covert_image_to_base64(image_path):
Expand All @@ -36,6 +37,9 @@ def format_cover_html(bot_name, bot_description, bot_avatar):
image_src = covert_image_to_base64(bot_avatar)
else:
image_src = '//img.alicdn.com/imgextra/i3/O1CN01YPqZFO1YNZerQfSBk_!!6000000003047-0-tps-225-225.jpg'
# Escape HTML to prevent XSS attacks
safe_bot_name = html.escape(bot_name or '')
safe_bot_description = html.escape(bot_description or '')
return f"""
<style>
body.dark-mode .bot_cover {{
Expand Down Expand Up @@ -74,7 +78,7 @@ def format_cover_html(bot_name, bot_description, bot_avatar):
<div class="bot_avatar">
<img src="{image_src}" />
</div>
<div class="bot_name">{bot_name}</div>
<div class="bot_desp">{bot_description}</div>
<div class="bot_name">{safe_bot_name}</div>
<div class="bot_desp">{safe_bot_description}</div>
</div>
"""