diff --git a/Aztec/Classes/TextKit/LayoutManager.swift b/Aztec/Classes/TextKit/LayoutManager.swift index 772aa7d23..fcf67aefa 100644 --- a/Aztec/Classes/TextKit/LayoutManager.swift +++ b/Aztec/Classes/TextKit/LayoutManager.swift @@ -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, diff --git a/CHANGELOG.md b/CHANGELOG.md index b0b4d1c21..aa41958ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/Example/Example/SampleContent/underline.html b/Example/Example/SampleContent/underline.html index fc73045a6..8fc94332b 100644 --- a/Example/Example/SampleContent/underline.html +++ b/Example/Example/SampleContent/underline.html @@ -4,3 +4,9 @@

Before link Link to WordPress

Before link Link to Jetpack After link

Link at end of textLink to Jetpack + + + قسم شنط  الكايلي   + + +لوقو انستجرام