diff --git a/submodules/Display/Display/TextNode.swift b/submodules/Display/Display/TextNode.swift index 77b59c9d30..7217a3cb4f 100644 --- a/submodules/Display/Display/TextNode.swift +++ b/submodules/Display/Display/TextNode.swift @@ -495,12 +495,12 @@ public final class TextNodeLayout: NSObject { return result } - public func attributeSubstring(name: String, index: Int) -> String? { + public func attributeSubstring(name: String, index: Int) -> (String, String)? { if let attributedString = self.attributedString { var range = NSRange() let _ = attributedString.attribute(NSAttributedString.Key(rawValue: name), at: index, effectiveRange: &range) if range.length != 0 { - return (attributedString.string as NSString).substring(with: range) + return ((attributedString.string as NSString).substring(with: range), attributedString.string) } } return nil @@ -755,7 +755,7 @@ public class TextNode: ASDisplayNode { return self.cachedLayout?.textRangesRects(text: text) ?? [] } - public func attributeSubstring(name: String, index: Int) -> String? { + public func attributeSubstring(name: String, index: Int) -> (String, String)? { return self.cachedLayout?.attributeSubstring(name: name, index: index) } diff --git a/submodules/TelegramUI/TelegramUI/ChatBotInfoItem.swift b/submodules/TelegramUI/TelegramUI/ChatBotInfoItem.swift index 8097d213a2..4e57b48327 100644 --- a/submodules/TelegramUI/TelegramUI/ChatBotInfoItem.swift +++ b/submodules/TelegramUI/TelegramUI/ChatBotInfoItem.swift @@ -268,8 +268,8 @@ final class ChatBotInfoItemNode: ListViewItemNode { if let (index, attributes) = self.textNode.attributesAtPoint(CGPoint(x: point.x - self.offsetContainer.frame.minX - textNodeFrame.minX, y: point.y - self.offsetContainer.frame.minY - textNodeFrame.minY)) { if let url = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] as? String { var concealed = true - if let attributeText = self.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) { - concealed = !doesUrlMatchText(url: url, text: attributeText) + if let (attributeText, fullText) = self.textNode.attributeSubstring(name: TelegramTextAttributes.URL, index: index) { + concealed = !doesUrlMatchText(url: url, text: attributeText, fullText: fullText) } return .url(url: url, concealed: concealed) } else if let peerMention = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.PeerMention)] as? TelegramPeerMention { diff --git a/submodules/TelegramUI/TelegramUI/ChatController.swift b/submodules/TelegramUI/TelegramUI/ChatController.swift index 46d3d6a382..666fd04d13 100644 --- a/submodules/TelegramUI/TelegramUI/ChatController.swift +++ b/submodules/TelegramUI/TelegramUI/ChatController.swift @@ -6875,11 +6875,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G } if concealed, let parsedUrlValue = parsedUrlValue, (parsedUrlValue.scheme == "http" || parsedUrlValue.scheme == "https"), !isConcealedUrlWhitelisted(parsedUrlValue) { - var displayUrl = url + var rawDisplayUrl = url let maxLength = 180 - if displayUrl.count > maxLength { - displayUrl = String(displayUrl[.. maxLength { + rawDisplayUrl = String(rawDisplayUrl[.. Bool { - for c in url { - if !c.isASCII { - return false - } +public func doesUrlMatchText(url: String, text: String, fullText: String) -> Bool { + if fullText.range(of: "\u{202e}") != nil { + return false } if url == text { return true