25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(mysql): prevent panic on Chinese characters in WHERE clause
bigliangzao764314870867
diff --git a/crates/dbx-core/src/db/mysql.rs b/crates/dbx-core/src/db/mysql.rsindex 7e5e5989a3..428959072c 100644--- a/crates/dbx-core/src/db/mysql.rs+++ b/crates/dbx-core/src/db/mysql.rs@@ -1468,7 +1468,11 @@ fn mysql_top_level_limit(sql: &str) -> Option<usize> {if depth == 0 && mysql_keyword_at(sql, i, "LIMIT") {return parse_mysql_limit_value(sql, i + "LIMIT".len());}+ // Move to next byte, but ensure we stay on a UTF-8 boundaryi += 1;+ while i < bytes.len() && !sql.is_char_boundary(i) {+ i += 1;+ }}None@@ -1497,13 +1501,20 @@ fn parse_usize_token(sql: &str, i: &mut usize) -> Option<usize> {if *i == start {return None;}- sql[start..*i].parse().ok()+ // Ensure the slice is valid UTF-8 before parsing+ std::str::from_utf8(&bytes[start..*i]).ok()?.parse().ok()}fn mysql_keyword_at(sql: &str, i: usize, keyword: &str) -> bool {let end = i + keyword.len();- end <= sql.len()- && sql[i..end].eq_ignore_ascii_case(keyword)+ if end > sql.len() {+ return false;+ }+ // Ensure indices are on UTF-8 boundaries before slicing+ if !sql.is_char_boundary(i) || !sql.is_char_boundary(end) {+ return false;+ }+ sql[i..end].eq_ignore_ascii_case(keyword)&& (i == 0 || !is_mysql_identifier_byte(sql.as_bytes()[i - 1]))&& (end == sql.len() || !is_mysql_identifier_byte(sql.as_bytes()[end]))}