Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2408] iOS: Application crashes when typing HTML special characters on TextArea

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionNeeds more info
Resolution Date2012-07-26T12:14:12.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterGuilherme Chapiewski
AssigneeNeeraj Gupta
Created2011-04-15T03:18:54.000+0000
Updated2012-07-26T21:58:46.000+0000

Description

When I type HTML special chars on a TeaxArea, my application crashes.

While monitoring the 'change' event, I noticed that Titanium is trying to replace (at least in the logs) the HTML entities for characters, which may be causing the error.

Here is the stack trace including my textarea logs:


[DEBUG] text is: & [DEBUG] text is: &l [DEBUG] text is: &lt [DEBUG] text is: < [DEBUG] text is: < [ERROR] The application has crashed with an unhandled exception. Stack trace: 0 CoreFoundation 0x03774b7c exceptionPreprocess + 156
1 libobjc.A.dylib 0x038c440e objc_exception_throw + 47
2 CoreFoundation 0x0372d238 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0372d1aa +[NSException raise:format:] + 58
4 Foundation 0x005a3e00 mutateError + 218
5 Foundation 0x005e5592 -[NSString stringByReplacingCharactersInRange:withString:] + 164
6 MemeiPad 0x00065237 -[TiUITextArea textView:shouldChangeTextInRange:replacementText:] + 81
7 UIKit 0x008a6074 -[UITextView keyboardInput:shouldInsertText:isMarkedText:] + 143
8 UIKit 0x008eca7b -[UIKeyboardImpl callShouldInsertText:] + 148
9 UIKit 0x008f4137 -[UIKeyboardImpl addInputString:fromVariantKey:] + 107
10 UIKit 0x008f64f8 -[UIKeyboardImpl handleKeyEvent:] + 1918
11 UIKit 0x007c4e5d -[UIApplication handleEvent:withNewEvent:] + 4631
12 UIKit 0x007bcb3c -[UIApplication sendEvent:] + 71
13 UIKit 0x007c19bf _UIApplicationHandleEvent + 7672
14 GraphicsServices 0x0535c822 PurpleEventCallback + 1550
15 CoreFoundation 0x03755ff4
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52
16 CoreFoundation 0x036b6807
CFRunLoopDoSource1 + 215
17 CoreFoundation 0x036b3a93 CFRunLoopRun + 979
18 CoreFoundation 0x036b3350 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x036b3271 CFRunLoopRunInMode + 97
20 GraphicsServices 0x0535b00c GSEventRunModal + 217
21 GraphicsServices 0x0535b0d1 GSEventRun + 115
22 UIKit 0x007c5af2 UIApplicationMain + 1160
23 MemeiPad 0x00002e9a main + 362
24 MemeiPad 0x00002571 start + 53
2010-11-23 14:54:28.934 MemeiPad[35235:207]
Terminating app due to uncaught exception 'NSRangeException', reason: ' -[NSCFString replaceCharactersInRange:withString:]: Range or index out of bounds'
*** Call stack at first throw: ( 0 CoreFoundation 0x03774b99 exceptionPreprocess + 185
1 libobjc.A.dylib 0x038c440e objc_exception_throw + 47
2 CoreFoundation 0x0372d238 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x0372d1aa +[NSException raise:format:] + 58
4 Foundation 0x005a3e00 mutateError + 218
5 Foundation 0x005e5592 -[NSString stringByReplacingCharactersInRange:withString:] + 164
6 MemeiPad 0x00065237 -[TiUITextArea textView:shouldChangeTextInRange:replacementText:] + 81
7 UIKit 0x008a6074 -[UITextView keyboardInput:shouldInsertText:isMarkedText:] + 143
8 UIKit 0x008eca7b -[UIKeyboardImpl callShouldInsertText:] + 148
9 UIKit 0x008f4137 -[UIKeyboardImpl addInputString:fromVariantKey:] + 107
10 UIKit 0x008f64f8 -[UIKeyboardImpl handleKeyEvent:] + 1918
11 UIKit 0x007c4e5d -[UIApplication handleEvent:withNewEvent:] + 4631
12 UIKit 0x007bcb3c -[UIApplication sendEvent:] + 71
13 UIKit 0x007c19bf _UIApplicationHandleEvent + 7672
14 GraphicsServices 0x0535c822 PurpleEventCallback + 1550
15 CoreFoundation 0x03755ff4 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 52
16 CoreFoundation 0x036b6807 CFRunLoopDoSource1 + 215
17 CoreFoundation 0x036b3a93
CFRunLoopRun + 979
18 CoreFoundation 0x036b3350 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x036b3271 CFRunLoopRunInMode + 97
20 GraphicsServices 0x0535b00c GSEventRunModal + 217
21 GraphicsServices 0x0535b0d1 GSEventRun + 115
22 UIKit 0x007c5af2 UIApplicationMain + 1160
23 MemeiPad 0x00002e9a main + 362
24 MemeiPad 0x00002571 start + 53
) terminate called after throwing an instance of 'NSException'

Attachments

FileDateSize
logs.txt2011-04-15T03:18:55.000+00003641

Comments

  1. Guilherme Chapiewski 2011-04-15

    Added logs as an attachment as well.

  2. Guilherme Chapiewski 2011-04-15

    The bug stopped happening after removing the replace on 'shouldChangeTextInRange' (TiUITextArea.m, line 136).

    Was:

    NSString *curText = [[tv text] stringByReplacingCharactersInRange:range withString:text];

    Changed to:

    NSString *curText = text;

  3. Dawson Toth 2011-04-15

    I have been able to reproduce this bug, but it only seems to happen when you also have invalid and valid HTML entities in your text area already.

    Sample Code

    Attached.

    Tested On

    BROKEN on iPhone Simulator 4.2

    Associated Helpdesk Ticket

    http://developer.appcelerator.com/helpdesk/view/64241">http://developer.appcelerator.com/helpdesk/view/64241

  4. Stephen Tramer 2012-07-26

    Does not include complete & valid test case.

    When this is resolved the ticket may be reopened.

JSON Source