From 175f5eaa9084b9fa7bb14d9dc9bd9b87be5ec1a5 Mon Sep 17 00:00:00 2001 From: He Wang Date: Wed, 23 Jul 2025 10:17:34 +0800 Subject: [PATCH] use quote_plus to escape password in opendal's mysql url (#8976) ### What problem does this PR solve? Use `quote_plus` to escape password in opendal's mysql url to support special characters like `#`. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/utils/opendal_conn.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rag/utils/opendal_conn.py b/rag/utils/opendal_conn.py index 731abf6d6..4167d4f0c 100644 --- a/rag/utils/opendal_conn.py +++ b/rag/utils/opendal_conn.py @@ -1,6 +1,7 @@ import opendal import logging import pymysql +from urllib.parse import quote_plus from api.utils import get_base_config from rag.utils import singleton @@ -35,7 +36,7 @@ def get_opendal_config(): "table": opendal_config.get("config").get("oss_table", "opendal_storage"), "max_allowed_packet": str(max_packet) } - kwargs["connection_string"] = f"mysql://{kwargs['user']}:{kwargs['password']}@{kwargs['host']}:{kwargs['port']}/{kwargs['database']}?max_allowed_packet={max_packet}" + kwargs["connection_string"] = f"mysql://{kwargs['user']}:{quote_plus(kwargs['password'])}@{kwargs['host']}:{kwargs['port']}/{kwargs['database']}?max_allowed_packet={max_packet}" else: scheme = opendal_config.get("scheme") config_data = opendal_config.get("config", {})