Skip to content

Commit

Permalink
Fix character escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
rleojoseph committed Oct 16, 2023
1 parent 9118a3a commit 2e99f67
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Sources/Classes/core/View/MiniAppViewHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,11 @@ extension MiniAppViewHandler: MiniAppCallbackDelegate {
}

func didReceiveEvent(_ event: MiniAppEvent, message: String) {
let messageBody = Constants.JavaScript.eventCallback + "('\(event.rawValue)'," + "'\(message)')"
var encodedMessage = message
if event == .miniappReceiveJsonString {
encodedMessage = message.base64Encoded() ?? ""
}
let messageBody = Constants.JavaScript.eventCallback + "('\(event.rawValue)'," + "'\(encodedMessage)')"
messageBodies.append(messageBody)
MiniAppLogger.d(messageBody, "♨️️")
webView?.evaluateJavaScript(messageBody)
Expand Down Expand Up @@ -933,3 +937,9 @@ extension MiniAppViewHandler {
}
}
// swiftlint:enable file_length function_body_length

extension String {
func base64Encoded() -> String? {
data(using: .utf8)?.base64EncodedString()
}
}

0 comments on commit 2e99f67

Please sign in to comment.