Skip to content

Commit

Permalink
Merge pull request #1384 from wordpress-mobile/fix/crash-underline-sp…
Browse files Browse the repository at this point in the history
…ecial-glyph

Fix crash when underlining text with special glyphs
  • Loading branch information
itsmeichigo authored Feb 2, 2024
2 parents 0f5c4eb + 950c7bc commit de17020
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Aztec/Classes/TextKit/LayoutManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ extension LayoutManager {
guard let textStorage = textStorage else {
return
}

guard Range(glyphRange, in: textStorage.string) != nil else {
// range out of bound for the glyph, fallback to default behavior
return super.underlineGlyphRange(glyphRange, underlineType: underlineVal, lineFragmentRect: lineRect, lineFragmentGlyphRange: lineGlyphRange, containerOrigin: containerOrigin)
}

let underlinedString = textStorage.attributedSubstring(from: glyphRange).string
var updatedGlyphRange = glyphRange
if glyphRange.endLocation == lineGlyphRange.endLocation,
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ _None._

### Bug Fixes

_None._
- Fixed crash when attempting to render Gutenberg comment. [#1383]
- Fixed crash when underlining text with special glyphs. [#1384]

### Internal Changes

Expand Down
6 changes: 6 additions & 0 deletions Example/Example/SampleContent/underline.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@
<p>Before link <a href="www.wordpress.com">Link&nbsp;to&nbsp;WordPress</a></p>
<p>Before link <a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a> After link</p>
Link at end of text<a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a>

<!-- underline for special glyphs --->
<a href="https://example.com/">&nbsp;قسم شنط &nbsp;الكايلي &nbsp;</a>

<!-- link for image with special glyphs in title/alt/data-image-description --->
<a href="https://www.wordpress.com/"><img class="alignnone wp-image-65" title="شنطة كايلي" src="https://www.wordpress.com/" alt="لوقو انستجرام" width="40" height="40" data-image-description="&lt;/p&gt; &lt;p&gt;لوقو انستجرام&lt;/p&gt; &lt;p&gt;" /></a>

0 comments on commit de17020

Please sign in to comment.