multiplatform: trim pasted migration link before reading its network config#7285
Draft
Narasimha-sc wants to merge 1 commit into
Draft
multiplatform: trim pasted migration link before reading its network config#7285Narasimha-sc wants to merge 1 commit into
Narasimha-sc wants to merge 1 commit into
Conversation
…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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-existing bug (present on
master, independent of any feature work — surfaced while reviewing the QR-type-recognition change but does not depend on it).Problem
MigrateToDevice.checkUserLinkgates onstrHasSimplexFileLink(link.trim())and storeslink.trim()in everyMigrationToStatepayload, but passes the raw, untrimmedlinktoMigrationFileLinkData.readFromLink:readFromLinksends the string into the core as/_download info <link>. With leading whitespace the core'sFileDescriptionURIparser fails,readFromLinkreturnsnull, and the link's network configuration is silently dropped — the migration then proceeds with the device's own host modes (getNetCfg()) instead of the link's, and the onion screen that the link's proxy config would have triggered is skipped.The link still downloads (the actual download uses
link.trim()from theMigrationToStatepayload), so the failure is silent: no error, just the wrong network settings applied.readFromLinkis a no-op stub that never readsnetworkConfig.Fix
Compute
val trimmed = link.trim()once and use it for the gate,readFromLink, and every payload — so classification and consumption see the same string and the raw/trimmed split cannot reappear. The only behavioural change isreadFromLinknow receiving the trimmed link.How to reproduce manually
Preconditions
A — control (unpadded link)
B — trigger (leading whitespace)
master: the onion screen is skipped; migration goes straight to database init using the device's default host modes. The link's network config is silently lost.Expected (and result with this fix): B behaves identically to A — the onion screen appears and the link's network config is applied, because leading whitespace is trimmed before the config is read.
Scope
One file,
apps/multiplatform/.../views/migration/MigrateToDevice.kt. No string, core, or API changes.