{ "id": "91757", "key": "TIMOB-9110", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2014-12-18T21:44:49.000+0000", "created": "2012-05-11T12:17:57.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "SupportTeam", "core" ], "versions": [ { "id": "13272", "description": "Release 2.0.1", "name": "Release 2.0.1", "archived": true, "released": true, "releaseDate": "2012-04-16" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-20T21:56:39.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": "h3. Problem\r\n\r\nThe replace javascript function does not work on a large base64 encoded string. Please run the code below to reproduce the issue. Also attached is the screenshot of the error.\r\n\r\n{noformat}\r\n\r\n(function() {\r\n \r\n var win = Ti.UI.createWindow({backgroundColor:'white'});\r\n win.open();\r\n var shortString = 'ABCDEFGHIJ1234567890ABCDEFGHIJ12|psndemo2|abcd:1';\r\n var longString = 'ABCDEFGHIJ1234567890ABCDEFGHIJ12|psndemo2|abcd:12345678901234567890';\r\n var tiBase64ShortResult = Ti.Utils.base64encode(shortString);\r\n var tiBase64LongResult = Ti.Utils.base64encode(longString);\r\n\r\n // BUG: without the two lines below get an error when trying to use \"replace\" on the base64 string\r\n //tiBase64ShortResult = String(tiBase64ShortResult);\r\n //tiBase64LongResult = String(tiBase64LongResult);\r\n\r\n \r\n tiBase64ShortResult = tiBase64ShortResult.replace(/\\r\\n/g,\"***NEWLINE***\");\r\n tiBase64LongResult = tiBase64LongResult.replace(/\\r\\n/g,\"***NEWLINE***\");\r\n var alertDialog = Titanium.UI.createAlertDialog(\r\n {\r\n title: 'Result', \r\n message: 'short: ' + tiBase64ShortResult + '\\nlong: ' + tiBase64LongResult, buttonNames: ['OK','Cancel'] \r\n });\r\n alertDialog.show();\r\n})();\r\n\r\n\r\n{noformat}\r\n\r\nThe issue is resolved on casting the output of base64 encode to a String. Is this an expected result?\r\n", "attachment": [ { "id": "27651", "filename": "Screen Shot 2012-05-11 at 3.16.53 PM.png", "author": { "name": "vjoshi", "key": "vjoshi", "displayName": "Varun Joshi", "active": true, "timeZone": "America/New_York" }, "created": "2012-05-11T12:17:57.000+0000", "size": 115085, "mimeType": "image/png" } ], "flagged": false, "summary": "iOS: javascript function replace not working on the result of Ti.Utils.base64encode", "creator": { "name": "vjoshi", "key": "vjoshi", "displayName": "Varun Joshi", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "vjoshi", "key": "vjoshi", "displayName": "Varun Joshi", "active": true, "timeZone": "America/New_York" }, "environment": "Titanium SDK: 2.0\r\nPlatform OS: iOS ", "comment": { "comments": [ { "id": "247259", "author": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue reproduces \n\nTested with\n\nTitanium Studio, build: 3.0.1.201212181159\nTitanium SDK version: 3.1.0 \nTitanium SDK version: 3.0.2 \niOS iPhone Simulator: iOS SDK version: 6.0", "updateAuthor": { "name": "jithinv@exalture.com", "key": "jithinv@exalture.com", "displayName": "jithinpv", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-12T09:45:01.000+0000", "updated": "2013-04-12T09:45:01.000+0000" }, { "id": "337028", "author": { "name": "iotashan", "key": "iotashan", "displayName": "Shannon Hicks", "active": true, "timeZone": "America/Chicago" }, "body": "This is not actually a bug. Docs say that Ti.Utils.base64encode() returns a Ti.Blob. Use Ti.Blob.toString() to convert to a String and all the String methods.", "updateAuthor": { "name": "iotashan", "key": "iotashan", "displayName": "Shannon Hicks", "active": true, "timeZone": "America/Chicago" }, "created": "2014-12-18T18:34:45.000+0000", "updated": "2014-12-18T18:34:45.000+0000" }, { "id": "337058", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Not a bug. Marking as such.", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-12-18T21:44:49.000+0000", "updated": "2014-12-18T21:44:49.000+0000" }, { "id": "414020", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-20T21:56:39.000+0000", "updated": "2017-03-20T21:56:39.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }