Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

Commit b5b303c

Browse files
authored
Merge pull request #13 from NoRespect/slackFormatEscaping
remove slackFormatEscaping
2 parents fcf3f74 + 2e4fa97 commit b5b303c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Sources/NetworkInterface.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ public struct NetworkInterface {
175175
// encoded when included in a query string. As a result, we need to manually apply the encoding after Apple's
176176
// default encoding is applied.
177177
var encodedQuery = components?.percentEncodedQuery
178+
encodedQuery = encodedQuery?.replacingOccurrences(of: ">", with: "%3E")
179+
encodedQuery = encodedQuery?.replacingOccurrences(of: "<", with: "%3C")
180+
encodedQuery = encodedQuery?.replacingOccurrences(of: "@", with: "%40")
181+
178182
encodedQuery = encodedQuery?.replacingOccurrences(of: "?", with: "%3F")
179183
encodedQuery = encodedQuery?.replacingOccurrences(of: "+", with: "%2B")
180184
components?.percentEncodedQuery = encodedQuery

Sources/WebAPI.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ extension WebAPI {
240240
public func sendMessage(
241241
channel: String,
242242
text: String,
243-
escapeCharacters: Bool = true,
244243
username: String? = nil,
245244
asUser: Bool? = nil,
246245
parse: ParseMode? = nil,
@@ -256,7 +255,7 @@ extension WebAPI {
256255
let parameters: [String: Any?] = [
257256
"token": token,
258257
"channel": channel,
259-
"text": escapeCharacters ? text.slackFormatEscaping : text,
258+
"text": text,
260259
"as_user": asUser,
261260
"parse": parse?.rawValue,
262261
"link_names": linkNames,
@@ -278,7 +277,6 @@ extension WebAPI {
278277
channel: String,
279278
thread: String,
280279
text: String,
281-
escapeCharacters: Bool = true,
282280
broadcastReply: Bool = false,
283281
username: String? = nil,
284282
asUser: Bool? = nil,
@@ -296,7 +294,7 @@ extension WebAPI {
296294
"token": token,
297295
"channel": channel,
298296
"thread_ts": thread,
299-
"text": escapeCharacters ? text.slackFormatEscaping : text,
297+
"text": text,
300298
"broadcastReply": broadcastReply,
301299
"as_user": asUser,
302300
"parse": parse?.rawValue,
@@ -318,11 +316,10 @@ extension WebAPI {
318316
public func sendMeMessage(
319317
channel: String,
320318
text: String,
321-
escapeCharacters: Bool = true,
322319
success: (((ts: String?, channel: String?)) -> Void)?,
323320
failure: FailureClosure?
324321
) {
325-
let parameters: [String: Any?] = ["token": token, "channel": channel, "text": escapeCharacters ? text.slackFormatEscaping : text]
322+
let parameters: [String: Any?] = ["token": token, "channel": channel, "text": text]
326323
networkInterface.request(.chatMeMessage, parameters: parameters, successClosure: {(response) in
327324
success?((ts: response["ts"] as? String, response["channel"] as? String))
328325
}) {(error) in
@@ -337,15 +334,14 @@ extension WebAPI {
337334
attachments: [Attachment?]? = nil,
338335
parse: ParseMode = .none,
339336
linkNames: Bool = false,
340-
escapeCharacters: Bool = true,
341337
success: SuccessClosure?,
342338
failure: FailureClosure?
343339
) {
344340
let parameters: [String: Any?] = [
345341
"token": token,
346342
"channel": channel,
347343
"ts": ts,
348-
"text": escapeCharacters ? message.slackFormatEscaping : message,
344+
"text": message,
349345
"parse": parse.rawValue,
350346
"link_names": linkNames,
351347
"attachments": encodeAttachments(attachments)
@@ -460,7 +456,7 @@ extension WebAPI {
460456
// MARK: - File Comments
461457
extension WebAPI {
462458
public func addFileComment(fileID: String, comment: String, success: CommentClosure?, failure: FailureClosure?) {
463-
let parameters: [String: Any] = ["token": token, "file": fileID, "comment": comment.slackFormatEscaping]
459+
let parameters: [String: Any] = ["token": token, "file": fileID, "comment": comment]
464460
networkInterface.request(.filesCommentsAdd, parameters: parameters, successClosure: {(response) in
465461
success?(Comment(comment: response["comment"] as? [String: Any]))
466462
}) {(error) in
@@ -469,7 +465,7 @@ extension WebAPI {
469465
}
470466

471467
public func editFileComment(fileID: String, commentID: String, comment: String, success: CommentClosure?, failure: FailureClosure?) {
472-
let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID, "comment": comment.slackFormatEscaping]
468+
let parameters: [String: Any] = ["token": token, "file": fileID, "id": commentID, "comment": comment]
473469
networkInterface.request(.filesCommentsEdit, parameters: parameters, successClosure: {(response) in
474470
success?(Comment(comment: response["comment"] as? [String: Any]))
475471
}) {(error) in

0 commit comments

Comments
 (0)