Skip to content

Commit d8027d4

Browse files
committed
encode channel name in request body for auth
1 parent b9abf1f commit d8027d4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Source/PusherConnection.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,12 @@ open class PusherConnection: NSObject {
620620
- returns: URLRequest object to be used by the function making the auth request
621621
*/
622622
fileprivate func requestForAuthValue(from endpoint: String, socketID: String, channel: PusherChannel) -> URLRequest {
623+
let allowedCharacterSet = CharacterSet(charactersIn: "!*'();:@&=+$,/?%#[] ").inverted
624+
let encodedChannelName = channel.name.addingPercentEncoding(withAllowedCharacters: allowedCharacterSet)
625+
623626
var request = URLRequest(url: URL(string: endpoint)!)
624627
request.httpMethod = "POST"
625-
request.httpBody = "socket_id=\(socketID)&channel_name=\(channel.name)".data(using: String.Encoding.utf8)
628+
request.httpBody = "socket_id=\(socketID)&channel_name=\(encodedChannelName!)".data(using: String.Encoding.utf8)
626629

627630
return request
628631
}

0 commit comments

Comments
 (0)