Skip to content

Commit 6892cd5

Browse files
cwisecarverChris Wisecarver
andauthored
Encode user agent as latin1 (#60)
Co-authored-by: Chris Wisecarver <[email protected]>
1 parent 63c857b commit 6892cd5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ParselyTracker/RequestBuilder.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class RequestBuilder {
3434
}
3535
let osDescriptor = String(format: "iOS/%@", UIDevice.current.systemVersion)
3636
let hardwareString = getHardwareString()
37-
userAgent = String(format: "%@ %@ (%@)", appDescriptor, osDescriptor, hardwareString)
37+
let userAgentString = String(format: "%@ %@ (%@)", appDescriptor, osDescriptor, hardwareString)
38+
// encode the user agent into latin1 in case there are utf8 characters
39+
let userAgentData = Data(userAgentString.utf8)
40+
userAgent = String(data: userAgentData, encoding: .isoLatin1)
3841
}
3942
return userAgent!
4043
}

0 commit comments

Comments
 (0)