multiplatform: trim pasted migration link before reading its network config

MigrateToDevice.checkUserLink gated on link.trim() and stored link.trim() in
every MigrationToState payload, but passed the raw, untrimmed link to
MigrationFileLinkData.readFromLink. A migration link pasted (or scanned) with
leading whitespace therefore passed the gate, then failed the "/_download info"
parse in the core, so readFromLink returned null and the link's network
configuration was silently dropped: the onion screen was skipped and migration
proceeded with the device's own host modes instead of the link's.

Compute the trimmed link once and use it throughout, so classification and
consumption see the same string.
This commit is contained in:
Narasimha-sc
2026-07-20 16:29:02 +00:00
parent 2ea5940e81
commit c328887e82
@@ -524,17 +524,18 @@ private fun ProgressView() {
}
private suspend fun MutableState<MigrationToState?>.checkUserLink(link: String): Boolean {
return if (strHasSimplexFileLink(link.trim())) {
val data = MigrationFileLinkData.readFromLink(link)
val trimmed = link.trim()
return if (strHasSimplexFileLink(trimmed)) {
val data = MigrationFileLinkData.readFromLink(trimmed)
val hasProxyConfigured = data?.networkConfig?.hasProxyConfigured() ?: false
val networkConfig = data?.networkConfig?.transformToPlatformSupported()
// If any of iOS or Android had onion enabled, show onion screen
if (hasProxyConfigured && networkConfig?.hostMode != null && networkConfig.requiredHostMode != null) {
state = MigrationToState.Onion(link.trim(), networkConfig.legacySocksProxy, networkConfig.networkProxy, networkConfig.hostMode, networkConfig.requiredHostMode)
MigrationToDeviceState.save(MigrationToDeviceState.Onion(link.trim(), networkConfig.legacySocksProxy, networkConfig.networkProxy, networkConfig.hostMode, networkConfig.requiredHostMode))
state = MigrationToState.Onion(trimmed, networkConfig.legacySocksProxy, networkConfig.networkProxy, networkConfig.hostMode, networkConfig.requiredHostMode)
MigrationToDeviceState.save(MigrationToDeviceState.Onion(trimmed, networkConfig.legacySocksProxy, networkConfig.networkProxy, networkConfig.hostMode, networkConfig.requiredHostMode))
} else {
val current = getNetCfg()
state = MigrationToState.DatabaseInit(link.trim(), current.copy(
state = MigrationToState.DatabaseInit(trimmed, current.copy(
socksProxy = null,
hostMode = networkConfig?.hostMode ?: current.hostMode,
requiredHostMode = networkConfig?.requiredHostMode ?: current.requiredHostMode