{ "id": "127454", "key": "TIMOB-16606", "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": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2017-08-08T21:13:45.000+0000", "created": "2014-03-08T19:01:09.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "defect", "ios" ], "versions": [ { "id": "15856", "description": "Release 3.2.1", "name": "Release 3.2.1", "archived": false, "released": true, "releaseDate": "2014-02-10" } ], "issuelinks": [], "assignee": { "name": "emerriman", "key": "emerriman", "displayName": "Eric Merriman ", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-08-15T20:14:15.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": "UPDATE: The strings I was using had non-breaking spaces in them (returned form the OS). Please read comments for more info.\r\n\r\nWhen a string that contains parentheses and spaces is base64 encoded then decoded into a blob, blob.text (and toString()) returns an invalid, truncated, string.\r\n\r\nBug appears to be is in base64encode when creating blob. If you paste the result encoded string into a decoder tool, you see the truncated string.\r\n\r\nmimetype of the resultant blob is 'application/octet-stream'.\r\n\r\nTested on iOS and Android. Bug appears only to exist on iOS.\r\n\r\nCode to reproduce:\r\n\r\n{code}\r\n var example = \"(602) 555-4848,(480) 555-5857,(480) 555-4849,(623) 555-7777,(303) 555-3030,(480) 555-1235,(480) 555-9998,(480) 555-2222\";\r\n var encoded = Ti.Utils.base64encode(example);\r\n var decoded = Ti.Utils.base64decode(encoded);\r\n Ti.API.debug('ORIGINAL :',example);\r\n Ti.API.debug('DECODED :',decoded.text);\r\n Ti.API.debug('ENCODED :',encoded.text);\r\n Ti.API.debug('CHECKS :',decoded.length, decoded.text.length, decoded.text === json);\r\n{code}\r\n\r\nOutput on iOS Simulator:\r\n\r\n{code}\r\n[DEBUG] : ORIGINAL : (602) 555-4848,(480) 555-5857,(480) 555-4849,(623) 555-7777,(303) 555-3030,(480) 555-1235,(480) 555-9998,(480) 555-2222\r\n[DEBUG] : DECODED : (602) 555-4848,(480) 555-5857,(480) 555-4849,(623) 555-7777,(303) 555-3030,(480) 555-1235,(480) 555-9998,(480) 555-22\r\n[DEBUG] : ENCODED : KDYwMinCoDU1NS00ODQ4LCg0ODApwqA1NTUtNTg1NywoNDgwKSA1NTUtNDg0OSwoNjIzKSA1\r\n[DEBUG] : NTUtNzc3NywoMzAzKSA1NTUtMzAzMCwoNDgwKSA1NTUtMTIzNSwoNDgwKSA1NTUtOTk5OCwo\r\n[DEBUG] : NDgwKSA1NTUtMjI=\r\n[DEBUG] : CHECKS : 119 117 0\r\n{code}", "attachment": [], "flagged": false, "summary": "iOS: base64encode does not handle extended ascii characters", "creator": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "subtasks": [], "reporter": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "environment": "Ti Version 3.2.1GA\r\nRunning on MacOSX Mavericks\r\n", "closedSprints": [ { "id": 933, "state": "closed", "name": "2017 Sprint 16 SDK", "startDate": "2017-07-30T16:17:10.306Z", "endDate": "2017-08-13T16:17:00.000Z", "completeDate": "2017-08-13T23:06:34.398Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "296232", "author": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "body": "(Updated to imply that the encode is the culprit after checking the encoded string in an external tool).\r\n\r\nCurious: why does the blob.length report the correct length even though .text is in fact truncated?", "updateAuthor": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "created": "2014-03-08T19:09:39.000+0000", "updated": "2014-03-08T19:09:39.000+0000" }, { "id": "296233", "author": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "body": "I just found out that on iOS the phone results from a device contacts query returns char code 160, non breaking spaces, between terms. Therefore, would this really be considered a bug or are base64 utils not intended to handle ascii codes >127?\r\n\r\nFor now, I'm just converting them to code 32.\r\n\r\n", "updateAuthor": { "name": "acemandinga", "key": "acemandinga", "displayName": "dennis booth", "active": true, "timeZone": "America/Phoenix" }, "created": "2014-03-08T20:33:02.000+0000", "updated": "2014-03-08T20:33:02.000+0000" }, { "id": "296526", "author": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Moving this ticket to engineering as I can reproduce the issue with a modified test case that uses characters with ascii code 162. Documentation does not specify the supported character list so it may either be a product bug or doc improvement.\r\n\r\n{code}\r\nvar example = \"¡¡¡¡¡¡¡¡¡¡\";\r\nvar encoded = Ti.Utils.base64encode(example);\r\nvar decoded = Ti.Utils.base64decode(encoded);\r\nTi.API.debug('ORIGINAL :',example);\r\nTi.API.debug('DECODED :',decoded.text);\r\nTi.API.debug('ENCODED :',encoded.text);\r\nTi.API.debug('CHECKS :',decoded.length, decoded.text.length, decoded.text === example);\r\n{code}\r\n", "updateAuthor": { "name": "ragrawal", "key": "ragrawal", "displayName": "Ritu Agrawal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2014-03-11T05:05:27.000+0000", "updated": "2014-03-11T05:05:27.000+0000" }, { "id": "426277", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Marking as duplicate of TIMOB-20395.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2017-08-08T21:13:45.000+0000", "updated": "2017-08-08T21:13:45.000+0000" }, { "id": "426703", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing as duplicate.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-08-15T20:14:15.000+0000", "updated": "2017-08-15T20:14:15.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }