-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Require matching email for iOS pairing #6028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 17 commits
ddaaa86
0050317
57b8589
b5b1fa3
de56d8e
0baf8a7
64e861e
2339bd2
a42dc7d
5cb9b73
5995237
bbacd8c
bb13811
b363f86
74632bb
c313540
becf69f
b3e3019
26b87b5
4be32eb
0452e49
d759c83
f7043f1
38f745e
e5beff0
7518ab7
6cb1647
a74a9fc
4a5dae3
af3c18b
7142689
3e506ec
173742f
005cedc
454c29f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,13 +12,21 @@ struct CompactAttachTicket: Codable { | |
| let w: String? | ||
| let t: String? | ||
| let d: String | ||
| let u: String? | ||
| let pc: Int? | ||
| let av: String? | ||
| let ab: String? | ||
| let r: [CompactAttachRoute] | ||
|
|
||
| init(_ ticket: CmxAttachTicket) { | ||
| v = ticket.version | ||
| w = Self.normalizedNonEmpty(ticket.workspaceID) | ||
| t = Self.normalizedNonEmpty(ticket.terminalID) | ||
| d = ticket.macDeviceID | ||
| u = Self.normalizedNonEmpty(ticket.macUserEmail) | ||
| pc = ticket.macPairingCompatibilityVersion | ||
| av = Self.normalizedNonEmpty(ticket.macAppVersion) | ||
| ab = Self.normalizedNonEmpty(ticket.macAppBuild) | ||
| r = Self.compactedRoutes(ticket.routes) | ||
| } | ||
|
Comment on lines
21
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Normalization inconsistency across metadata fields.
Since these values come from controlled sources (authenticated email, Bundle info), the practical risk is low, but consistency would prevent subtle edge-case bugs. 🔧 Proposed fix to align normalizationUpdate private static func normalizedNonEmpty(_ value: String?) -> String? {
- guard let value, !value.isEmpty else {
- return nil
- }
- return value
+ let trimmed = value?.trimmingCharacters(in: .whitespacesAndNewlines)
+ return trimmed?.isEmpty == false ? trimmed : nil
}Note: This also affects 🤖 Prompt for AI Agents |
||
|
|
||
|
|
@@ -29,6 +37,10 @@ struct CompactAttachTicket: Codable { | |
| terminalID: t, | ||
| macDeviceID: d, | ||
| macDisplayName: nil, | ||
| macUserEmail: u, | ||
| macPairingCompatibilityVersion: pc, | ||
| macAppVersion: av, | ||
| macAppBuild: ab, | ||
| routes: Self.expandedRoutes(r), | ||
| expiresAt: nil | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial | 💤 Low value
Consider explicit handling when percent-encoding fails.
The fallback
?? valuereturns the original unencoded value ifaddingPercentEncodingfails. For email addresses with+(e.g.,user+tag@example.com) or versions with special characters, this could inject reserved characters into the URL query, potentially breaking parsing.While encoding failure is rare for typical email/version strings, explicit handling would be more defensive.
🛡️ Safer fallback options
Option 1: Return empty string and skip the parameter:
func percentEncodeQueryValue(_ value: String) -> String { var allowed = CharacterSet.urlQueryAllowed allowed.remove(charactersIn: "&=+") - return value.addingPercentEncoding(withAllowedCharacters: allowed) ?? value + return value.addingPercentEncoding(withAllowedCharacters: allowed) ?? "" }Then filter empty results:
if let email = normalizedNonEmpty(ticket.macUserEmail) { - items.append("e=\(percentEncodeQueryValue(email))") + let encoded = percentEncodeQueryValue(email) + if !encoded.isEmpty { + items.append("e=\(encoded)") + } }Option 2: Use a safe placeholder:
📝 Committable suggestion
🤖 Prompt for AI Agents