Skip to content

Commit

Permalink
Safely handle end-of-line
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai-Holler committed Mar 7, 2019
1 parent e725cb6 commit ceb9b67
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
static constexpr CGSize kRectOffsets[9] = {
{ 0, 0 },
{ -22, 0 }, { 22, 0 },
{ 0, -22 } , { 0, 22 },
{ 0, -22 }, { 0, 22 },
{ -22, -22 }, { -22, 22 },
{ 22, -22 }, { 22, 22 }
};
Expand All @@ -616,6 +616,9 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
const CGPoint testPoint = CGPointMake(point.x + offset.width,
point.y + offset.height);
ASTextPosition *pos = [layout closestPositionToPoint:testPoint];
if (!pos || !NSLocationInRange(pos.offset, clampedRange)) {
continue;
}
for (NSString *attributeName in _linkAttributeNames) {
NSRange effectiveRange = NSMakeRange(0, 0);
id value = [_attributedText attribute:attributeName atIndex:pos.offset
Expand All @@ -642,7 +645,6 @@ - (id)_linkAttributeValueAtPoint:(CGPoint)point
return value;
}
}


return nil;
}
Expand Down

0 comments on commit ceb9b67

Please sign in to comment.