{ "id": "63040", "key": "TIMOB-2408", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": { "id": "8", "description": "", "name": "Needs more info" }, "resolutiondate": "2012-07-26T12:14:12.000+0000", "created": "2011-04-15T03:18:54.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11233", "name": "Release 1.6.0", "archived": true, "released": true, "releaseDate": "2011-02-23" } ], "issuelinks": [ { "id": "19355", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "94532", "key": "TIMOB-9901", "fields": { "summary": "TiAPI: Review and clean up platform bugs and reduce bug count by 20%.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } } ], "assignee": { "name": "ngupta", "key": "ngupta", "displayName": "Neeraj Gupta", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-07-26T21:58:46.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

When I type HTML special chars on a TeaxArea, my application\r\ncrashes.

\r\n

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

\r\n

Here is the stack trace including my textarea logs:

\r\n
\r\n

[DEBUG] text is: & [DEBUG] text is: &l [DEBUG] text is: &lt [DEBUG] text is: < [DEBUG] text is: < [ERROR] The application has crashed with an\r\nunhandled exception. Stack trace: 0 CoreFoundation 0x03774b7c\r\nexceptionPreprocess + 156
\r\n1 libobjc.A.dylib 0x038c440e objc_exception_throw + 47
\r\n2 CoreFoundation 0x0372d238 +[NSException raise:format:arguments:]\r\n+ 136
\r\n3 CoreFoundation 0x0372d1aa +[NSException raise:format:] + 58
\r\n4 Foundation 0x005a3e00 mutateError + 218
\r\n5 Foundation 0x005e5592 -[NSString\r\nstringByReplacingCharactersInRange:withString:] + 164
\r\n6 MemeiPad 0x00065237 -[TiUITextArea\r\ntextView:shouldChangeTextInRange:replacementText:] + 81
\r\n7 UIKit 0x008a6074 -[UITextView\r\nkeyboardInput:shouldInsertText:isMarkedText:] + 143
\r\n8 UIKit 0x008eca7b -[UIKeyboardImpl callShouldInsertText:] +\r\n148
\r\n9 UIKit 0x008f4137 -[UIKeyboardImpl addInputString:fromVariantKey:]\r\n+ 107
\r\n10 UIKit 0x008f64f8 -[UIKeyboardImpl handleKeyEvent:] + 1918
\r\n11 UIKit 0x007c4e5d -[UIApplication handleEvent:withNewEvent:] +\r\n4631
\r\n12 UIKit 0x007bcb3c -[UIApplication sendEvent:] + 71
\r\n13 UIKit 0x007c19bf _UIApplicationHandleEvent + 7672
\r\n14 GraphicsServices 0x0535c822 PurpleEventCallback + 1550
\r\n15 CoreFoundation 0x03755ff4
\r\nCFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION +\r\n52
\r\n16 CoreFoundation 0x036b6807
CFRunLoopDoSource1 + 215
\r\n17 CoreFoundation 0x036b3a93 CFRunLoopRun + 979
\r\n18 CoreFoundation 0x036b3350 CFRunLoopRunSpecific + 208
\r\n19 CoreFoundation 0x036b3271 CFRunLoopRunInMode + 97
\r\n20 GraphicsServices 0x0535b00c GSEventRunModal + 217
\r\n21 GraphicsServices 0x0535b0d1 GSEventRun + 115
\r\n22 UIKit 0x007c5af2 UIApplicationMain + 1160
\r\n23 MemeiPad 0x00002e9a main + 362
\r\n24 MemeiPad 0x00002571 start + 53
\r\n2010-11-23 14:54:28.934 MemeiPad[35235:207]
\r\nTerminating app due to uncaught exception 'NSRangeException',\r\nreason: ' -[NSCFString replaceCharactersInRange:withString:]:\r\nRange or index out of bounds'
\r\n*** Call stack at first throw: ( 0 CoreFoundation 0x03774b99\r\nexceptionPreprocess + 185
\r\n1 libobjc.A.dylib 0x038c440e objc_exception_throw + 47
\r\n2 CoreFoundation 0x0372d238 +[NSException raise:format:arguments:]\r\n+ 136
\r\n3 CoreFoundation 0x0372d1aa +[NSException raise:format:] + 58
\r\n4 Foundation 0x005a3e00 mutateError + 218
\r\n5 Foundation 0x005e5592 -[NSString\r\nstringByReplacingCharactersInRange:withString:] + 164
\r\n6 MemeiPad 0x00065237 -[TiUITextArea\r\ntextView:shouldChangeTextInRange:replacementText:] + 81
\r\n7 UIKit 0x008a6074 -[UITextView\r\nkeyboardInput:shouldInsertText:isMarkedText:] + 143
\r\n8 UIKit 0x008eca7b -[UIKeyboardImpl callShouldInsertText:] +\r\n148
\r\n9 UIKit 0x008f4137 -[UIKeyboardImpl addInputString:fromVariantKey:]\r\n+ 107
\r\n10 UIKit 0x008f64f8 -[UIKeyboardImpl handleKeyEvent:] + 1918
\r\n11 UIKit 0x007c4e5d -[UIApplication handleEvent:withNewEvent:] +\r\n4631
\r\n12 UIKit 0x007bcb3c -[UIApplication sendEvent:] + 71
\r\n13 UIKit 0x007c19bf _UIApplicationHandleEvent + 7672
\r\n14 GraphicsServices 0x0535c822 PurpleEventCallback + 1550
\r\n15 CoreFoundation 0x03755ff4\r\nCFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION\r\n+ 52
\r\n16 CoreFoundation 0x036b6807 CFRunLoopDoSource1 + 215
\r\n17 CoreFoundation 0x036b3a93
CFRunLoopRun + 979
\r\n18 CoreFoundation 0x036b3350 CFRunLoopRunSpecific + 208
\r\n19 CoreFoundation 0x036b3271 CFRunLoopRunInMode + 97
\r\n20 GraphicsServices 0x0535b00c GSEventRunModal + 217
\r\n21 GraphicsServices 0x0535b0d1 GSEventRun + 115
\r\n22 UIKit 0x007c5af2 UIApplicationMain + 1160
\r\n23 MemeiPad 0x00002e9a main + 362
\r\n24 MemeiPad 0x00002571 start + 53
\r\n) terminate called after throwing an instance of 'NSException'

{html}", "attachment": [ { "id": "18144", "filename": "logs.txt", "author": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:18:55.000+0000", "size": 3641, "mimeType": "text/plain" } ], "flagged": false, "summary": "iOS: Application crashes when typing HTML special characters on TextArea", "creator": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "128382", "author": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Added logs as an attachment as well.

{html}", "updateAuthor": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:18:55.000+0000", "updated": "2011-04-15T03:18:55.000+0000" }, { "id": "128383", "author": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

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

\n

Was:

\n

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

\n

Changed to:

\n

NSString *curText = text;

{html}", "updateAuthor": { "name": "guilhermechapiewski", "key": "guilhermechapiewski", "displayName": "Guilherme Chapiewski", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:18:55.000+0000", "updated": "2011-04-15T03:18:55.000+0000" }, { "id": "128384", "author": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "body": "{html}

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

\n

Sample Code

\n

Attached.

\n

Tested On

\n

BROKEN on iPhone Simulator 4.2

\n

Associated Helpdesk Ticket

\n

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

{html}", "updateAuthor": { "name": "dtoth", "key": "dtoth", "displayName": "Dawson Toth", "active": true, "timeZone": "America/New_York" }, "created": "2011-04-15T03:18:55.000+0000", "updated": "2011-04-15T03:18:55.000+0000" }, { "id": "209683", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "# Does not include complete & valid test case.\r\n\r\nWhen this is resolved the ticket may be reopened.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-07-26T12:14:12.000+0000", "updated": "2012-07-26T12:14:12.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }