Skip to content

Commit de17020

Browse files
authored
Merge pull request #1384 from wordpress-mobile/fix/crash-underline-special-glyph
Fix crash when underlining text with special glyphs
2 parents 0f5c4eb + 950c7bc commit de17020

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

Aztec/Classes/TextKit/LayoutManager.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,12 @@ extension LayoutManager {
366366
guard let textStorage = textStorage else {
367367
return
368368
}
369+
370+
guard Range(glyphRange, in: textStorage.string) != nil else {
371+
// range out of bound for the glyph, fallback to default behavior
372+
return super.underlineGlyphRange(glyphRange, underlineType: underlineVal, lineFragmentRect: lineRect, lineFragmentGlyphRange: lineGlyphRange, containerOrigin: containerOrigin)
373+
}
374+
369375
let underlinedString = textStorage.attributedSubstring(from: glyphRange).string
370376
var updatedGlyphRange = glyphRange
371377
if glyphRange.endLocation == lineGlyphRange.endLocation,

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ _None._
4242

4343
### Bug Fixes
4444

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

4748
### Internal Changes
4849

Example/Example/SampleContent/underline.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
<p>Before link <a href="www.wordpress.com">Link&nbsp;to&nbsp;WordPress</a></p>
55
<p>Before link <a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a> After link</p>
66
Link at end of text<a href="www.jetpack.com">Link&nbsp;to&nbsp;Jetpack</a>
7+
8+
<!-- underline for special glyphs --->
9+
<a href="https://example.com/">&nbsp;قسم شنط &nbsp;الكايلي &nbsp;</a>
10+
11+
<!-- link for image with special glyphs in title/alt/data-image-description --->
12+
<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 commit comments

Comments
 (0)