Describe the bug
Using react-native-enriched, email that feature an image before a link crash the renderer.
To Reproduce
Pass this html into EnrichedTextInput
<html><img src="data:," /><img src="data:," /><img src="data:," /><p>See <a href="https://example.com">a link</a></p></html>
Get this crash
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '-[__NSCFString substringWithRange:]: Range {7, 6} out of bounds; string length 10'
Root cause: HtmlParser.mm:698 does [plainText substringWithRange:tagRangeValue.rangeValue] where the range was built at :166 in final-NSTextStorage coords (counts +1 per
), but plainText doesn’t contain the image placeholders. Any link finalized while precedingImageCount > 0 overruns plainText by that count. Triggered in our app on a real ~5.3KB email with 3 images and a trailing link (overrun by 3, matching the math). Fix is a one-site clamp before :698.
Expected behavior
HTML should not crash
Describe the bug
Using react-native-enriched, email that feature an image before a link crash the renderer.
To Reproduce
Pass this html into
EnrichedTextInputGet this crash
Root cause: HtmlParser.mm:698 does [plainText substringWithRange:tagRangeValue.rangeValue] where the range was built at :166 in final-NSTextStorage coords (counts +1 per
), but plainText doesn’t contain the image placeholders. Any link finalized while precedingImageCount > 0 overruns plainText by that count. Triggered in our app on a real ~5.3KB email with 3 images and a trailing link (overrun by 3, matching the math). Fix is a one-site clamp before :698.
Expected behavior
HTML should not crash