Repository navigation
Conversation
AppLink read the decoded queryItems and then swapped + for space, which cannot tell a form space from a literal plus: a search for c++ arrives as q=c%2B%2B, decodes to c++, and the swap corrupted it to c-followed- by-spaces. Reading percentEncodedQueryItems instead restores the order the encoding defines: plus to space first, percent-decoding after. Closes AssemblyAI#459
This branch has not been deployed
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.
What & why
Fixes #459.
AppLink.name(in:)readURLComponents.queryItems— already percent-decoded — and then swapped"+"for space. Form encoding defines"+"as a space before percent-decoding, so the swap order is backwards: a literal plus, correctly encoded as%2Bby whoever wrote the link, decodes to"+"and is then corrupted to a space. A google search forc++(q=c%2B%2B) extracted as"c ", and the mangled text is whatpreferAppsmatches installed app names against.The fix reads
percentEncodedQueryItems— the still-encoded items — applies the plus swap first, and percent-decodes after, which is the order the encoding defines.removingPercentEncodingreturning nil on a malformed sequence is handled by the same guard as the rest.How it was tested
The decode path is pure Foundation, so both orderings were verified byte-for-byte on Linux Swift 6.2.4 before committing:
q=c%2B%2B"c ""c++"q=a+b"a b""a b"q=a%20b"a b""a b"q=%2B" ""+"Regression test added to
AppLinkTestspinningq=c%2B%2B→"c++". The existing suite's cases are encoding-neutral (q=how+to+open+threads+in+slackstill exceeds the word gate).scripts/check.sh --portablegreen end-to-end;swift-format lint --strictclean on both files. CI on macos-26 is the authority on the Swift build and test run.scripts/check.shpasses (or CI will, if I'm not on a Mac)