RedMadRobot / input-mask-ios

User input masking library repo.
MIT License
578 stars 96 forks source link

Terminating app due to "Range or index out of bounds" exception #84

Closed CFIFok closed 1 year ago

CFIFok commented 4 years ago

Prerequisites

Describe the bug

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds' in MaskedTextFieldDelegate.swift class.

Steps to reproduce the behaviour:

  1. Create an instance of UITextField with default properties, listener (MaskedTextFieldDelegateListener) and delegate (MaskedTextFieldDelegate) 1.1. The delegate should be an instance with primaryFormat: "[000000]"(for example [000000], but it can be either [00] or [000] etc.). The main point is that it should have some kind of symbols limitation.
  2. Copy more than 6 symbols in clipboard (depend on the number of zeros in the format [000000]).
  3. Run the application and navigate to the our UITextField.
  4. Perform *three-finger gesture on the UITextField and tap Paste button (Screenshot 1) twice. The size limit should be exceeded, but everything will be ok.
  5. And finally press the Undo button (Screenshot 1).
  6. Crash!

I have made some analysis of this issue and draw conclusions which are depicted on Screenshot 2. Thank you for your cooperation in advance.

Expected behaviour The delegate should perform the undo operation, if possible, otherwise make nothing.

Actual behaviour Terminating app due to "Range or index out of bounds" exception.

Screenshots Screenshot 1 IMG_001 Screenshot 2 IMG_002

Platform information

Additional context *iOS provides built-in gestures for undo, redo, copy, and paste in text views, triggered using a variety of three-finger moves – swiping left and right, or pinching in or out respectively: https://www.apple.com/ios/ios-13/features/

taflanidi commented 4 years ago

Hey @CFIFok! Thanks a lot for you heaven-of-a-detailed cool report, things like this massively assist with debugging.

Speaking of which, we'll have an update this week with a few tweaks, and I'd like to include the fix for this bug as well.

alkincakiralar1996 commented 2 years ago

Any updates ?

taflanidi commented 1 year ago

Update is coming in 7.2.0 :D

That's a marvelous catch, thank you so much!

taflanidi commented 1 year ago

@CFIFok mind if I add you to our contributors?

taflanidi commented 1 year ago

Meet 7.2.0.

alexander-kurilovich-gismart commented 1 year ago

@taflanidi yep sure! Thanx a lot too 👍