浏览代码

filter non-numeric characters before generating an tel:// url

cyberta 4 年之前
父节点
当前提交
09d25c2635
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      deltachat-ios/Chat/ChatViewController.swift

+ 3 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -1302,10 +1302,11 @@ extension ChatViewController: BaseMessageCellDelegate {
         if handleUIMenu() || handleSelection(indexPath: indexPath) {
         if handleUIMenu() || handleSelection(indexPath: indexPath) {
             return
             return
         }
         }
-        if let phoneURL = URL(string: "tel://\(number)") {
+        let sanitizedNumber = number.filter("0123456789".contains)
+        if let phoneURL = URL(string: "tel://\(sanitizedNumber)") {
             UIApplication.shared.open(phoneURL, options: [:], completionHandler: nil)
             UIApplication.shared.open(phoneURL, options: [:], completionHandler: nil)
         }
         }
-        logger.debug("phone number tapped \(number)")
+        logger.debug("phone number tapped \(sanitizedNumber)")
     }
     }
 
 
     @objc func commandTapped(command: String, indexPath: IndexPath) {
     @objc func commandTapped(command: String, indexPath: IndexPath) {