fix(connection): strip invisible characters from saved credentials

This commit is contained in:
U1 authored and GitHub committed 2026-09-14 22:49:15 +08:00
1 parent e84e49fa28
commit a5bb8cf1c1
4 files changed
+145 -1

No files matched your search

@@ -42,6 +42,7 @@ import type { NacosAdminConfig, NacosApiPlane, NacosAuthConfig, NacosImplementat
import { CONNECTION_ATTEMPT_CANCELLED_MESSAGE, useConnectionStore } from "@/stores/connectionStore";
import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";
import { detachTunnelProfileLayer, tunnelProfileReferenceLayer, tunnelProfileSummary } from "@/lib/connection/tunnelProfiles";
import { sanitizeConnectionCredentials } from "@/lib/connection/credentialSanitizer";
import { applySshAuthMethod, inferSshAuthMethod } from "@/lib/connection/sshAuthMethod";
import { applySshConfigHostAliasPrefill as prefillSshConfigHostAlias } from "@/lib/connection/sshConfigHosts";
import { canPersistConnectionTestResult, connectionEditDraftSyncAction } from "./connectionEditDraftSync";
@@ -4573,6 +4574,8 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
if (!config.show_system_schemas) config.show_system_schemas = undefined;
if (config.visible_schemas && Object.keys(config.visible_schemas).length === 0) config.visible_schemas = undefined;
if (config.agent_java_options && config.agent_java_options.length === 0) config.agent_java_options = undefined;
// Pasted credentials may carry invisible characters that trim() keeps (#9043).
sanitizeConnectionCredentials(config);
return config as ConnectionConfig;
}
@@ -14,6 +14,7 @@ import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";
import { createTunnelProfile, createTunnelProfileTestGuard, tunnelProfileSummary, type TunnelProfileType } from "@/lib/connection/tunnelProfiles";
import { applySshConfigHostAliasPrefill as prefillSshConfigHostAlias } from "@/lib/connection/sshConfigHosts";
import { applySshAuthMethod } from "@/lib/connection/sshAuthMethod";
import { stripInvisibleCharactersFromLayer } from "@/lib/connection/credentialSanitizer";
import * as api from "@/lib/backend/api";
import type { SshConfigHostEntry, TunnelProfile } from "@/types/database";
import { translateBackendError } from "@/i18n/backend-errors";
@@ -151,7 +152,10 @@ async function save() {
invalidateProfileTest();
isSaving.value = true;
try {
await store.saveProfiles(cloneProfiles(draft.value));
// Pasted credentials may carry invisible characters that trim() keeps (#9043).
const sanitized = cloneProfiles(draft.value);
sanitized.forEach(stripInvisibleCharactersFromLayer);
await store.saveProfiles(sanitized);
toast(t("settings.tunnelsSaved"));
} catch (error) {
toast(t("settings.tunnelsSaveFailed", { message: translateBackendError(t, error) }), 5000);