Wallet: fixed ton:// url escaping

This commit is contained in:
Ilya Laktyushin 2019-09-28 00:30:33 +03:00
parent 0df16d868d
commit d36b7afdc3
3 changed files with 5 additions and 11 deletions

View File

@ -17,11 +17,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>XPC!</string> <string>XPC!</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<<<<<<< HEAD
<string>$(PRODUCT_BUNDLE_SHORT_VERSION)</string> <string>$(PRODUCT_BUNDLE_SHORT_VERSION)</string>
=======
<string>5.12</string>
>>>>>>> 5b85b9dffa9d63ffaa35f448e3903bcd7b9f2156
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>${BUILD_NUMBER}</string> <string>${BUILD_NUMBER}</string>
<key>NSExtension</key> <key>NSExtension</key>

View File

@ -28,6 +28,7 @@ static_library(
"//submodules/TelegramStringFormatting:TelegramStringFormatting", "//submodules/TelegramStringFormatting:TelegramStringFormatting",
"//submodules/GlassButtonNode:GlassButtonNode", "//submodules/GlassButtonNode:GlassButtonNode",
"//submodules/UrlHandling:UrlHandling", "//submodules/UrlHandling:UrlHandling",
"//submodules/UrlEscaping:UrlEscaping",
"//submodules/LocalAuth:LocalAuth", "//submodules/LocalAuth:LocalAuth",
], ],
frameworks = [ frameworks = [

View File

@ -11,6 +11,7 @@ import ItemListUI
import SwiftSignalKit import SwiftSignalKit
import OverlayStatusController import OverlayStatusController
import ShareController import ShareController
import UrlEscaping
private final class WalletReceiveScreenArguments { private final class WalletReceiveScreenArguments {
let context: AccountContext let context: AccountContext
@ -275,7 +276,7 @@ private func walletReceiveScreenEntries(presentationData: PresentationData, addr
addressText = formatAddress(address) addressText = formatAddress(address)
addressMonospace = true addressMonospace = true
} else { } else {
addressText = invoiceUrl(address: address, state: state, escapeComment: false) addressText = invoiceUrl(address: address, state: state, escapeComment: true)
} }
entries.append(.address(presentationData.theme, addressText, addressMonospace)) entries.append(.address(presentationData.theme, addressText, addressMonospace))
entries.append(.copyAddress(presentationData.theme, state.isEmpty ? presentationData.strings.Wallet_Receive_CopyAddress : presentationData.strings.Wallet_Receive_CopyInvoiceUrl)) entries.append(.copyAddress(presentationData.theme, state.isEmpty ? presentationData.strings.Wallet_Receive_CopyAddress : presentationData.strings.Wallet_Receive_CopyInvoiceUrl))
@ -306,13 +307,9 @@ private func invoiceUrl(address: String, state: WalletReceiveScreenState, escape
arguments += arguments.isEmpty ? "?" : "&" arguments += arguments.isEmpty ? "?" : "&"
arguments += "amount=\(amountValue(state.amount))" arguments += "amount=\(amountValue(state.amount))"
} }
if !state.comment.isEmpty, let escapedComment = state.comment.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { if !state.comment.isEmpty {
arguments += arguments.isEmpty ? "?" : "&" arguments += arguments.isEmpty ? "?" : "&"
if escapeComment { arguments += "text=\(urlEncodedStringFromString(state.comment))"
arguments += "text=\(escapedComment)"
} else {
arguments += "text=\(state.comment)"
}
} }
return "ton://transfer/\(address)\(arguments)" return "ton://transfer/\(address)\(arguments)"
} }