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(oracle): keep copied connection URL credentials readable (#12020)
zipg78b1de514120
diff --git a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.tsindex 6a1d37bf1c..ae826da73c 100644--- a/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts+++ b/apps/desktop/src/lib/__tests__/connection/connectionUrlBuilder.spec.ts@@ -86,6 +86,24 @@ describe("buildConnectionUrlCopy standard URL", () => {expect(parseConnectionUrl(text ?? "").password).toBe(ASCII_SYMBOLS);});+ it("keeps Oracle URL credentials readable instead of escaping `^` as `%5E`", () => {+ const oracle = config({ db_type: "oracle", host: "10.89.67.210", port: 1521, username: "GSU_ZXQ", password: "W^j.U.ZUm5Th", database: "optpdb" });+ const text = buildConnectionUrlCopy(oracle, "urlWithPassword");+ expect(text).toBe("oracle://GSU_ZXQ:W^[email protected]:1521/optpdb");+ expect(parseConnectionUrl(text ?? "").password).toBe("W^j.U.ZUm5Th");+ });++ it("still escapes the Oracle URL credentials that would change how the URL is read", () => {+ const oracle = config({ db_type: "oracle", host: "ora.example.com", port: 1521, username: "app_user", password: "p^ss%40#y@x", database: "ORCLPDB1" });+ const text = buildConnectionUrlCopy(oracle, "urlWithPassword");+ expect(text).toBe("oracle://app_user:p^ss%2540%23y%[email protected]:1521/ORCLPDB1");+ expect(parseConnectionUrl(text ?? "").password).toBe("p^ss%40#y@x");+ });++ it("keeps the full percent-encoding for dialects whose URL a driver consumes", () => {+ expect(buildConnectionUrlCopy(config({ password: "W^j.U" }), "urlWithPassword")).toBe("postgresql://app_user:W%[email protected]:5432/appdb");+ });+it("preserves credentials that already look percent-encoded", () => {const password = "%25%40%5E";const text = buildConnectionUrlCopy(config({ password }), "urlWithPassword");diff --git a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts b/apps/desktop/src/lib/connection/connectionUrlBuilder.tsindex 55084ff038..92f4c4bba0 100644--- a/apps/desktop/src/lib/connection/connectionUrlBuilder.ts+++ b/apps/desktop/src/lib/connection/connectionUrlBuilder.ts@@ -193,16 +193,33 @@ function encodeCredential(value: string): string {return encodeURIComponent(value).replace(/[!'()*]/g, (character) => `%${character.charCodeAt(0).toString(16).toUpperCase()}`);}-function buildUserInfo(config: ConnectionUrlCopyConfig, includePassword: boolean): string {+/**+ * Characters an Oracle `oracle://` credential keeps verbatim: the RFC 3986+ * unreserved and sub-delim sets, plus `^`.+ *+ * Oracle has no URL client, so this string is a DBX interchange format and+ * Oracle never percent-decodes credentials (the same reason the Oracle JDBC+ * item below keeps them literal, issue #11612). Emitting `%5E` for `^` made+ * users read a password that differs from the one they typed (issue #10057+ * follow-up), while `%`, the userinfo/path delimiters and whitespace must stay+ * escaped for the copy to import as the same credential.+ */+const ORACLE_URL_CREDENTIAL_LITERAL_CHARACTERS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&'()*+,;=^");++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 {const user = effectiveUsername(config);const password = config.password ?? "";if (includePassword) {- if (user && password) return `${encodeCredential(user)}:${encodeCredential(password)}@`;- if (user) return `${encodeCredential(user)}@`;- if (password) return `:${encodeCredential(password)}@`;+ if (user && password) return `${encode(user)}:${encode(password)}@`;+ if (user) return `${encode(user)}@`;+ if (password) return `:${encode(password)}@`;return "";}- return user ? `${encodeCredential(user)}@` : "";+ return user ? `${encode(user)}@` : "";}function standardUrlScheme(config: ConnectionUrlCopyConfig): string | null {@@ -255,7 +272,7 @@ function buildStandardUrl(config: ConnectionUrlCopyConfig, options: ConnectionUrif (!host) return null;const database = effectiveDatabase(config, options);- const userInfo = buildUserInfo(config, options.includePassword);+ const userInfo = buildUserInfo(config, options.includePassword, config.db_type === "oracle" ? encodeOracleUrlCredential : encodeCredential);const hostPart = formatHostForUrl(host);const portPart = shouldAppendPort(config) ? `:${config.port}` : "";const path = database ? `/${encodeURIComponent(database)}` : "";