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(sidebar): show oceanbase usernames without escaping at
efeireead985d0b937
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vueindex 1528d0f0d7..1c7c8f1665 100644--- a/apps/desktop/src/components/sidebar/TreeItem.vue+++ b/apps/desktop/src/components/sidebar/TreeItem.vue@@ -55,6 +55,7 @@ import { Badge } from "@/components/ui/badge";import { Input } from "@/components/ui/input";import { Switch } from "@/components/ui/switch";import LightTooltip from "@/components/ui/LightTooltip.vue";+import { encodeOceanBaseUrlUsername } from "@/lib/connection/connectionUrlBuilder";import type { ColumnInfo, ConnectionConfig, CustomTypeTreeMemberMeta, DatabaseType, TreeNode, TriggerInfo } from "@/types/database";import { alignedCommentLeadingWidth, canTreeNodePin, canTreeNodeShowExpander, isSidebarCommentSupportedType, sidebarTreeNodeComment, trailingCommentAvailableWidth, trailingCommentGapPx, treeItemPaddingLeft, treeLabelWidthClass, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";import {@@ -555,7 +556,8 @@ function connectionTooltipUrl(config: ConnectionConfig): string {const scheme = connectionDisplayUrlScheme(config);const port = Number(config.port) > 0 ? `:${config.port}` : "";const user = cleanTooltipValue(config.username);- const userInfo = user ? `${encodeURIComponent(user)}@` : "";+ const encodedUser = config.db_type === "mysql" && config.driver_profile?.trim().toLowerCase() === "oceanbase" ? encodeOceanBaseUrlUsername(user) : encodeURIComponent(user).replace(/%40/g, "@");+ const userInfo = user ? `${encodedUser}@` : "";const database = tooltipDatabaseValue(config);const encodedDatabase = config.db_type === "spanner" ? encodeSpannerResourcePath(database) : encodeURIComponent(database);const path = database ? `/${encodedDatabase}` : "";diff --git a/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts b/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.tsindex 8f41931d26..c502f75249 100644--- a/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts+++ b/apps/desktop/src/components/sidebar/__tests__/TreeItem.visibleFilterDetail.spec.ts@@ -7,6 +7,8 @@ import TreeItem from "@/components/sidebar/TreeItem.vue";import { createSidebarTreeRuntime, sidebarTreeRuntimeKey, type SidebarTreeRuntimeHost } from "@/lib/sidebar/sidebarTreeRuntime";import type { SidebarVisibleFilterSummary } from "@/lib/sidebar/sidebarVisibleFilterSummary";import type { ConnectionConfig, TreeNode } from "@/types/database";+import { buildConnectionUrlCopy } from "@/lib/connection/connectionUrlBuilder";+import { parseConnectionUrl } from "@/lib/connection/connectionUrl";const state: {config: ConnectionConfig;@@ -139,6 +141,37 @@ afterEach(() => {});describe("TreeItem visible filter connection detail", () => {+ it("shows the tenant separator without URL escaping while copied URLs remain round-trippable", async () => {+ state.config = { ...mysqlConnection(), driver_profile: "oceanbase", username: "admin@tenant", port: 2881, url_params: "password=synthetic-secret" };++ await openConnectionTooltip();++ expect(document.body.textContent).toContain("mysql://admin@[email protected]:2881/filter_alpha?password=***");+ expect(document.body.textContent).not.toContain("synthetic-secret");+ const copied = buildConnectionUrlCopy(state.config, "url")!;+ expect(copied).toContain("admin@tenant@");+ expect(parseConnectionUrl(copied).username).toBe("admin@tenant");+ });++ it("keeps other username delimiters escaped and preserves literal percent-looking text", async () => {+ state.config = { ...mysqlConnection(), username: "user:name@tenant%40cluster", password: "synthetic-secret" };++ await openConnectionTooltip();++ expect(document.body.textContent).toContain("mysql://user%3Aname@tenant%[email protected]:3306/filter_alpha");+ expect(document.body.textContent).not.toContain("synthetic-secret");+ });++ it("uses the same readable OceanBase username punctuation in previews and copies", async () => {+ const username = "u!$()*,=@tenant";+ state.config = { ...mysqlConnection(), driver_profile: "oceanbase", username };++ await openConnectionTooltip();++ expect(document.body.textContent).toContain("mysql://" + username + "@127.0.0.1:3306/filter_alpha");+ expect(buildConnectionUrlCopy(state.config, "url")).toContain("oceanbase://" + username + "@");+ });+it("shows an active database filter count in the connection tooltip", async () => {const { host, node } = await openConnectionTooltip();diff --git a/apps/desktop/src/lib/__tests__/connection/connectionStringRedaction.spec.ts b/apps/desktop/src/lib/__tests__/connection/connectionStringRedaction.spec.tsindex cc037d9db4..a6db136ff9 100644--- a/apps/desktop/src/lib/__tests__/connection/connectionStringRedaction.spec.ts+++ b/apps/desktop/src/lib/__tests__/connection/connectionStringRedaction.spec.ts@@ -3,6 +3,10 @@ import { redactConnectionStringSecrets } from "@/lib/connection/connectionStringdescribe("shared connection string redaction", () => {it.each([+ ["oceanbase://admin@tenant@cluster:synthetic%40secret@[2001:db8::1]:2881/app?password=another-secret", "oceanbase://admin@tenant@cluster:***@[2001:db8::1]:2881/app?password=***"],+ ["OCEANBASE://admin@tenant:[email protected]:2881/app", "OCEANBASE://admin@tenant:***@db.example.com:2881/app"],+ ["oceanbase://admin@tenant:p@ss;secret@[2001:db8::1]:2881/app", "oceanbase://admin@tenant:***@[2001:db8::1]:2881/app"],+ ["oceanbase://admin@[email protected]:2881/app", "oceanbase://admin@[email protected]:2881/app"],["redis://:[email protected]:6379/0", "redis://:***@cache.example.com:6379/0"],["jdbc:mysql://db.example.com/app?pass%77ord=synthetic-secret&connectTimeout=5000", "jdbc:mysql://db.example.com/app?pass%77ord=***&connectTimeout=5000"],["postgresql://db.example.com/app?sslpassword=key-secret&oauth_client_secret=client-secret", "postgresql://db.example.com/app?sslpassword=***&oauth_client_secret=***"],diff --git a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.tsindex 94520da364..a4377586b0 100644--- a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts+++ b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts@@ -22,6 +22,72 @@ const ASCII_SYMBOLS = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";// stored credential for clients that never percent-decode.const ENCODED_ASCII_SYMBOLS = "%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F%3A%3B%3C=%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~";+describe("OceanBase copy readability and compatibility", () => {+ const oceanbase = (overrides: Partial<ConnectionUrlCopyConfig> = {}) => config({ db_type: "mysql", driver_profile: "oceanbase", port: 2881, username: "admin@tenant@cluster", ...overrides });++ it("keeps tenant names readable across the four copy formats", () => {+ const connection = oceanbase();+ expect(buildConnectionUrlCopy(connection, "url")).toBe("oceanbase://admin@tenant@[email protected]:2881/appdb");+ expect(buildConnectionUrlCopy(connection, "urlWithPassword")).toBe("oceanbase://admin@tenant@cluster:[email protected]:2881/appdb");+ expect(buildConnectionUrlCopy(connection, "jdbcUrl")).toBe("jdbc:oceanbase://db.example.com:2881/appdb");+ expect(buildConnectionUrlCopy(connection, "jdbcUrlWithCredentials")).toBe("jdbc:oceanbase://db.example.com:2881/appdb?user=admin@tenant@cluster&password=secret");+ expect(connectionUrlCopyFormats(connection)).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort"]);+ for (const format of ["url", "urlWithPassword", "jdbcUrlWithCredentials"] as const) {+ const parsed = parseConnectionUrl(buildConnectionUrlCopy(connection, format)!);+ expect(parsed.username).toBe(connection.username);+ expect(parsed.host).toBe(connection.host);+ expect(parsed.port).toBe(2881);+ expect(parsed.password).toBe(format === "url" ? "" : connection.password);+ }+ });++ it("keeps safe punctuation readable without changing ordinary MySQL encoding", () => {+ const username = "u!$()*,=@tenant";+ expect(buildConnectionUrlCopy(oceanbase({ username }), "url")).toContain(username + "@");+ expect(buildConnectionUrlCopy(oceanbase({ password: "p!$()*,=" }), "urlWithPassword")).toContain(":p!$()*,=@");+ expect(buildConnectionUrlCopy(config({ db_type: "mysql", username }), "url")).toContain("u%21%24%28%29%2A%2C=%40tenant@");+ });++ it("round-trips all standard URL credential symbols and IPv6 without losing escaping boundaries", () => {+ const connection = oceanbase({ username: "u" + ASCII_SYMBOLS + "@tenant", password: "p" + ASCII_SYMBOLS, host: "2001:db8::1" });+ const text = buildConnectionUrlCopy(connection, "urlWithPassword")!;+ expect(text).toContain("%27");+ expect(text).toContain("%40");+ const parsed = parseConnectionUrl(text);+ expect(parsed.username).toBe(connection.username);+ expect(parsed.password).toBe(connection.password);+ expect(parsed.port).toBe(connection.port);+ expect(parsed.database).toBe(connection.database);+ expect(new URL(text).hostname).toBe("[2001:db8::1]");+ });++ it("uses literal JDBC property values instead of percent-encoded credentials", () => {+ const value = "a!$()*+,=:@/?[]<>`|^{}\\中文b";+ const text = buildConnectionUrlCopy(oceanbase({ username: value, password: value }), "jdbcUrlWithCredentials")!;+ expect(text).toContain("user=" + value + "&password=" + value);+ expect(parseConnectionUrl(text).username).toBe(value);+ expect(parseConnectionUrl(text).password).toBe(value);+ });++ it.each(["&", ";", "'", '"', "#", "%40", " ", "\n", "\t"])("does not offer a JDBC credential URL that cannot preserve %j", (symbol) => {+ for (const field of ["username", "password"] as const) {+ const connection = oceanbase({ [field]: "a" + symbol + "b" });+ expect(buildConnectionUrlCopy(connection, "jdbcUrlWithCredentials")).toBeNull();+ expect(connectionUrlCopyFormats(connection)).not.toContain("jdbcUrlWithCredentials");+ expect(connectionUrlCopyFormats(connection)).toContain("urlWithPassword");+ expect(parseConnectionUrl(buildConnectionUrlCopy(connection, "urlWithPassword")!)[field]).toBe(connection[field]);+ }+ });++ it("preserves explicit strings while redacting passwords behind raw tenant names", () => {+ const explicit = "oceanbase://admin@tenant:synthetic%[email protected]:2881/appdb";+ expect(buildConnectionUrlCopy(oceanbase({ connection_string: explicit }), "url")).toBe("oceanbase://admin@tenant:***@db.example.com:2881/appdb");+ expect(buildConnectionUrlCopy(oceanbase({ connection_string: explicit }), "urlWithPassword")).toBe(explicit);+ const jdbc = "jdbc:oceanbase://db.example.com:2881/appdb?user=literal%40tenant&password=secret";+ expect(buildConnectionUrlCopy(oceanbase({ connection_string: jdbc }), "jdbcUrlWithCredentials")).toBe(jdbc);+ });+});+describe("connectionUrlCopyFormats", () => {it("lists all formats for a PostgreSQL connection with a stored password", () => {expect(connectionUrlCopyFormats(config({}))).toEqual(["url", "urlWithPassword", "jdbcUrl", "jdbcUrlWithCredentials", "hostPort", "dsn", "dsnWithPassword", "psqlCommand"]);diff --git a/apps/desktop/src/lib/connection/connectionStringRedaction.ts b/apps/desktop/src/lib/connection/connectionStringRedaction.tsindex 0f8b13db23..e0d700f37b 100644--- a/apps/desktop/src/lib/connection/connectionStringRedaction.ts+++ b/apps/desktop/src/lib/connection/connectionStringRedaction.ts@@ -3,7 +3,8 @@ import { isSecretConnectionProperty, redactJdbcProperties, redactSqlServerQuery/** Shared by copyable connection strings and sidebar previews. */export function redactConnectionStringSecrets(value: string): string {// Password-only userinfo (for example redis://:password@host) is valid too.- const withoutUserInfo = value.replace(/(:\/\/[^/\s:@?#;]*):([^@\s/?#;]+)@/g, "$1:***@");+ const redactedOceanBase = value.replace(/^(oceanbase:\/\/[^/\s:?#]*):([^\s/?#]+)@/i, "$1:***@");+ const withoutUserInfo = redactedOceanBase.replace(/(:\/\/[^/\s:@?#;]*):([^@\s/?#;]+)@/g, "$1:***@");const properties = withoutUserInfo.match(/^(jdbc:sqlserver:\/\/[^;]*;)([\s\S]*)$/i) ?? withoutUserInfo.match(/^(jdbc:teradata:\/\/[^/]*\/)([\s\S]*)$/i);if (properties) return properties[1] + redactJdbcProperties(properties[2], /^jdbc:sqlserver:/i.test(withoutUserInfo) ? "sqlserver" : "teradata");const sqlServerQuery = withoutUserInfo.match(/^(mssql:\/\/[^?]*\?)([\s\S]*)$/i);diff --git a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts b/apps/desktop/src/lib/connection/connectionUrlBuilder.tsindex 1c611964af..9ceb33cd78 100644--- a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts+++ b/apps/desktop/src/lib/connection/connectionUrlBuilder.ts@@ -203,6 +203,15 @@ function encodeCredential(value: string): string {.replace(/%3D/g, "=");}+function encodeOceanBaseUrlCredential(value: string): string {+ return encodeCredential(value).replace(/%(21|24|28|29|2A|2C)/g, decodeURIComponent);+}++/** Tenant separators stay readable in OceanBase URL previews and copies. */+export function encodeOceanBaseUrlUsername(value: string): string {+ return encodeOceanBaseUrlCredential(value).replace(/%40/g, "@");+}+/*** Characters an Oracle `oracle://` credential keeps verbatim: the RFC 3986* unreserved and sub-delim sets, plus `^`.@@ -220,16 +229,16 @@ function encodeOracleUrlCredential(value: string): string {return Array.from(value, (character) => (ORACLE_URL_CREDENTIAL_LITERAL_CHARACTERS.has(character) ? character : encodeURIComponent(character))).join("");}-function buildUserInfo(config: ConnectionUrlCopyConfig, includePassword: boolean, encode: (value: string) => string = encodeCredential): string {+function buildUserInfo(config: ConnectionUrlCopyConfig, includePassword: boolean, encode: (value: string) => string = encodeCredential, encodeUser: (value: string) => string = encode): string {const user = effectiveUsername(config);const password = config.password ?? "";if (includePassword) {- if (user && password) return `${encode(user)}:${encode(password)}@`;- if (user) return `${encode(user)}@`;+ if (user && password) return `${encodeUser(user)}:${encode(password)}@`;+ if (user) return `${encodeUser(user)}@`;if (password) return `:${encode(password)}@`;return "";}- return user ? `${encode(user)}@` : "";+ return user ? `${encodeUser(user)}@` : "";}function standardUrlScheme(config: ConnectionUrlCopyConfig): string | null {@@ -282,7 +291,8 @@ function buildStandardUrl(config: ConnectionUrlCopyConfig, options: ConnectionUrif (!host) return null;const database = effectiveDatabase(config, options);- const userInfo = buildUserInfo(config, options.includePassword, config.db_type === "oracle" ? encodeOracleUrlCredential : encodeCredential);+ const encode = scheme === "oceanbase" ? encodeOceanBaseUrlCredential : config.db_type === "oracle" ? encodeOracleUrlCredential : encodeCredential;+ const userInfo = buildUserInfo(config, options.includePassword, encode, scheme === "oceanbase" ? encodeOceanBaseUrlUsername : encode);const hostPart = formatHostForUrl(host);const portPart = shouldAppendPort(config) ? `:${config.port}` : "";const path = database ? `/${encodeURIComponent(database)}` : "";@@ -444,8 +454,8 @@ function buildSpecialJdbcUrl(config: ConnectionUrlCopyConfig, database: string,function jdbcQuery(config: ConnectionUrlCopyConfig, prefix: string, withCredentials: boolean): string {const raw = (config.url_params ?? "").trim().replace(/^[?&]+/, "");- // Strict encoding is enabled only for verified query-style drivers.- const encode = MYSQL_QUERY_JDBC_PREFIXES.has(prefix) || prefix === "jdbc:postgresql" ? encodeCredential : encodeURIComponent;+ // OceanBase uses literal property values; other verified query-style drivers use percent encoding.+ const encode = prefix === "jdbc:oceanbase" ? (value: string) => value : MYSQL_QUERY_JDBC_PREFIXES.has(prefix) || prefix === "jdbc:postgresql" ? encodeCredential : encodeURIComponent;const parts = [...jdbcCredentialParams(config, withCredentials, encode)];if (raw) parts.push(raw);if (config.ssl) {@@ -472,6 +482,8 @@ function buildJdbcUrl(config: ConnectionUrlCopyConfig, options: ConnectionUrlCopconst prefix = jdbcPrefixFor(config);if (!prefix) return null;+ // The driver uses literal properties; these characters cannot also round-trip through the URL importer.+ if (prefix === "jdbc:oceanbase" && options.withCredentials && [effectiveUsername(config), config.password ?? ""].some((value) => /[&;'"#%\s]/.test(value))) return null;const portPart = shouldAppendPort(config) ? `:${config.port}` : "";const path = database ? `/${encodeURIComponent(database)}` : "";const query = jdbcQuery(config, prefix, options.withCredentials);