Skip to content

Commit 529a886

Browse files
authored
Fix link tap crash in Reader (#23845)
1 parent a785180 commit 529a886

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

WordPress/Classes/ViewRelated/Views/WPRichText/WPRichContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ extension WPRichContentView: UIGestureRecognizerDelegate {
558558
let point = touch.location(in: self)
559559
let characterIndex = self.layoutManager.characterIndex(for: point, in: self.textContainer, fractionOfDistanceBetweenInsertionPoints: nil)
560560
// handle tap on link
561-
if let linkAttribute = self.attributedText?.attribute(.link, at: characterIndex, effectiveRange: nil) {
561+
if let attributedText, characterIndex >= 0 && characterIndex < attributedText.length, let linkAttribute = attributedText.attribute(.link, at: characterIndex, effectiveRange: nil) {
562562
return linkAttribute is URL
563563
}
564564

0 commit comments

Comments
 (0)