wordpress-mobile / AztecEditor-iOS

A reusable native iOS visual HTML text editor component.
Mozilla Public License 2.0
615 stars 147 forks source link

iOS 17 crashes when calling `String.paragraphRange` #1374

Closed twstokes closed 1 year ago

twstokes commented 1 year ago

Describe the bug iOS 17 crashes when String.paragraphRange(for:) is called when the range passed in is for a single paragraph separator character: \u{2029}

To Reproduce Steps to reproduce the behavior:

  1. Run the AztecExample demo app in the Simulator or on a real device
  2. Tap "Standard Demo"
  3. Place the cursor at the end of the top line "Welcome to Aztec"
  4. Erase characters until the app crashes

Expected behavior The app to erase the characters without crashing.

Screenshots

Video Exception
Screenshot 2023-09-11 at 16 36 49

Smartphone (please complete the following information):

Additional context

The following Playground in Xcode 16 will reproduce the crash:

import Foundation

/// Fails when using Xcode 16.0 beta 8 Playground and when running on iOS 17 beta.
let paragraphSeparator = "\u{2029}"

/// Try adding a character before or after the separator - it should not crash.
let string = paragraphSeparator
let range = string.startIndex ..< string.endIndex

/// Throws an exception.
let outRange = string.paragraphRange(for: range)
/// Success if this was reached.
print(string)
twstokes commented 1 year ago

Apple Feedback has been submitted: FB13142115

This issue will be resolved in iOS 17.1. Thanks @kean for testing and confirming!