Project: titanium
Issue TIMOB-19211: iOS: Tapping "undo" will get a range or index out of bounds on TiUITextField
h6.Issue Description Tapping "Undo" button will result in application crashing. h6.Steps to Replicate A Ti.UI.Textfield that will only allow numeric characters (0 to 9 and .) Textfiled has keyboard type of Ti.UI.KEYBOARD_DECIMAL_PAD. 1. Started the application. 2. Tapping on numbers will update the textfield and tapping on undo will clear the textfield (This is expected behaviour). 3. Tapping on other characters present on the keyboard that are not numeric and then tapping on the undo button will result in application crashing. h6.Test Case {code} var changeCallback = function(e) { e.source.value = e.source.value.replace(new RegExp("[^0-9.]"), ""); }; var window = Ti.UI.createWindow({ layout : 'vertical', backgroundColor : 'white', height : Ti.UI.FILL, width : Ti.UI.FILL }); var sampleTest = Ti.UI.createTextField({ height : 40, width : Titanium.UI.FILL, keyboardType : Ti.UI.KEYBOARD_DECIMAL_PAD, top : 50, left : 50, borderWidth : 1, borderColor : "blue", maxLength : 53, hintText : 'Here goes the sample text', value : '', }); sampleTest.addEventListener("change", changeCallback); window.add(sampleTest); window.open(); {code} h6.Crash logs {code} -- Start application log ----------------------------------------------------- [INFO] dropDown/1.0 (4.2.0.afcd782) [ERROR] The application has crashed with an uncaught exception 'NSRangeException'. [ERROR] Reason: [ERROR] -[__NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds [ERROR] Stack trace: [ERROR] [ERROR] 0 CoreFoundation 0x0000000185d3a530 + 132 [ERROR] 1 libobjc.A.dylib 0x0000000196cf80e4 objc_exception_throw + 60 [ERROR] 2 CoreFoundation 0x0000000185d3a470 + 0 [ERROR] 3 CoreFoundation 0x0000000185ce4ed0 + 256 [ERROR] 4 Foundation 0x0000000186c2dec4 + 160 [ERROR] 5 dropDown 0x000000010014cf30 dropDown + 429872 [ERROR] 6 UIKit 0x000000018ac9beec + 112 [ERROR] 7 UIKit 0x000000018aca1760 + 108 [ERROR] 8 UIKit 0x000000018acfcae8 + 268 [ERROR] 9 Foundation 0x0000000186c75960 + 308 [ERROR] 10 Foundation 0x0000000186c74584 + 468 [ERROR] 11 UIKit 0x000000018a712030 + 640 [ERROR] 12 UIKit 0x000000018a711ca0 + 644 [ERROR] 13 UIKit 0x000000018a705db4 + 3784 [ERROR] 14 UIKit 0x000000018a704d48 + 1428 [ERROR] 15 UIKit 0x000000018a7046d0 + 252 [ERROR] 16 UIKit 0x000000018a570630 + 388 [ERROR] 17 UIKit 0x000000018a700e3c + 272 [ERROR] 18 UIKit 0x000000018a700bf4 + 392 [ERROR] 19 UIKit 0x000000018a57c03c + 700 [ERROR] 20 UIKit 0x000000018a575590 + 684 [ERROR] 21 UIKit 0x000000018a548e60 + 264 [ERROR] 22 UIKit 0x000000018a7e846c + 15220 [ERROR] 23 UIKit 0x000000018a5473d0 + 1716 [ERROR] 24 CoreFoundation 0x0000000185cf2d34 + 24 [ERROR] 25 CoreFoundation 0x0000000185cf1fd8 + 264 [ERROR] 26 CoreFoundation 0x0000000185cf0088 + 712 [ERROR] 27 CoreFoundation 0x0000000185c1d1f4 CFRunLoopRunSpecific + 396 [ERROR] 28 GraphicsServices 0x000000018ef3f6fc GSEventRunModal + 168 [ERROR] 29 UIKit 0x000000018a5ae10c UIApplicationMain + 1488 [ERROR] 30 dropDown 0x00000001000ebbec dropDown + 31724 [ERROR] 31 libdyld.dylib 0x0000000197376a08 + 4 [ERROR] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds' [ERROR] *** First throw call stack: [ERROR] (0x185d3a530 0x196cf80e4 0x185d3a470 0x185ce4ed0 0x186c2dec4 0x10014cf30 0x18ac9beec 0x18aca1760 0x18acfcae8 0x186c75960 0x186c74584 0x18a712030 0x18a711ca0 0x18a705db4 0x18a704d48 0x18a7046d0 0x18a570630 0x18a700e3c 0x18a700bf4 0x18a57c03c 0x18a575590 0x18a548e60 0x18a7e846c 0x18a5473d0 0x185cf2d34 0x185cf1fd8 0x185cf0088 0x185c1d1f4 0x18ef3f6fc 0x18a5ae10c 0x1000ebbec 0x197376a08) {code}
Story points: 3