{ "id": "77340", "key": "TIMOB-4546", "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": "2017-06-16T22:25:29.000+0000", "created": "2011-07-04T16:44:18.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [], "versions": [ { "id": "11367", "description": "", "name": "Release 1.7.1", "archived": true, "released": true, "releaseDate": "2011-06-21" } ], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-16T22:25:29.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": "10202", "name": "Android", "description": "Android Platform" } ], "description": "Note the somewhat related TIMOB-4543\r\n\r\nWhen a path that uses \"dot-dot\" filesystem path notation (ie {{../}}, to signify \"move to parent directory\") is passed to {{Ti.Filesystem.getFile}}, an exception is generated on 1.7.1, but executes as expected on 1.6.3. One of the difficulties this causes is that database files cannot be accessed via the {{Ti.Filesystem.applicationDataDirectory}} path, making it necessary for users to use [messy workarounds|http://developer.appcelerator.com/question/96771/location-of-titanium-sql-database-on-android#answer-172981], ie: {{'file:///data/data/' + Ti.App.getID() + '/databases/'}}\r\n\r\nThe following code demonstrates the issue:\r\n\r\n{code:lang=javascript}\r\nvar fileName = 'test7.txt';\r\nTi.API.info(\"fileName: \" + fileName);\r\nvar filePath = Ti.Filesystem.applicationDataDirectory + '../databases';\r\nTi.API.info(\"filePath: \" + filePath);\r\nvar thisFile = Ti.Filesystem.getFile(filePath, fileName);\r\nTi.API.info(\"thisFile.nativePath: \" + thisFile.nativePath);\r\n{code}\r\n\r\nWhen run on 1.6.3, no exception is generated:\r\n*Titanium 1.6.3 (2011/05/06 13:58 7b34a7...)*\r\n{code} \r\n10289 KrollContext D (kroll$1: app://app.js) [337,735] Running evaluated script: file:///android_asset/Resources/app.js\r\n 10289 dalvikvm D GC_FOR_MALLOC freed 4836 objects / 323320 bytes in 56ms\r\n 10289 TiAPI I (kroll$1: app://app.js) [375,1110] fileName: test7.txt\r\n 10289 TiAPI I (kroll$1: app://app.js) [2,1112] filePath: appdata-private://../databases\r\n 10289 TiAPI I (kroll$1: app://app.js) [21,1133] thisFile.nativePath: file:///data/data/com.testing.testing7/app_appdata/../databases/test7.txt\r\n 10289 TiRootActivity I (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44ec6910 \r\n{code}\r\n\r\nWhen run on 1.7.1, an exception is generated:\r\n*Titanium 1.7.1 (2011/06/17 00:13 293a6d...)*\r\n{code}\r\n 9285 KrollContext D (kroll$1: app://app.js) [2,1172] Running evaluated script: file:///android_asset/Resources/app.js\r\n 9285 TiAPI I (kroll$1: app://app.js) [101,1273] fileName: test7.txt\r\n 9285 TiAPI I (kroll$1: app://app.js) [2,1275] filePath: appdata-private://../databases\r\n 9285 KrollMethod E (kroll$1: app://app.js) [15,1290] Exception calling kroll method getFile, invocation: null ]\r\n 9285 KrollMethod E java.lang.NullPointerException\r\n 9285 KrollMethod E \tat java.net.URI$Helper.isValidDomainName(URI.java:631)\r\n 9285 KrollMethod E \tat java.net.URI$Helper.isValidHost(URI.java:595)\r\n 9285 KrollMethod E \tat java.net.URI$Helper.parseAuthority(URI.java:544)\r\n 9285 KrollMethod E \tat java.net.URI$Helper.parseURI(URI.java:404)\r\n 9285 KrollMethod E \tat java.net.URI$Helper.access$100(URI.java:302)\r\n 9285 KrollMethod E \tat java.net.URI.(URI.java:87)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.util.TiUrl.absoluteUrl(TiUrl.java:251)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.util.TiUrl.resolve(TiUrl.java:195)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.TiContext.resolveUrl(TiContext.java:151)\r\n 9285 KrollMethod E \tat ti.modules.titanium.filesystem.FileProxy.(FileProxy.java:80)\r\n 9285 KrollMethod E \tat ti.modules.titanium.filesystem.FileProxy.(FileProxy.java:49)\r\n 9285 KrollMethod E \tat ti.modules.titanium.filesystem.FilesystemModule.getFile(FilesystemModule.java:69)\r\n 9285 KrollMethod E \tat ti.modules.titanium.filesystem.FilesystemModuleBindingGen$8.invoke(FilesystemModuleBindingGen.java:346)\r\n 9285 KrollMethod E \tat org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)\r\n 9285 KrollMethod E \tat org.mozilla.javascript.Context.evaluateReader(Context.java:1142)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:105)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:306)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:318)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:217)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223)\r\n 9285 KrollMethod E \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n 9285 KrollMethod E \tat android.os.Looper.loop(Looper.java:123)\r\n 9285 KrollMethod E \tat org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)\r\n 9285 KrollContext E (kroll$1: app://app.js) [25,1315] Error evaluating source: Wrapped java.lang.NullPointerException (file:///android_asset/Resources/app.js#1042)\r\n 9285 KrollContext E org.mozilla.javascript.WrappedException: Wrapped java.lang.NullPointerException (file:///android_asset/Resources/app.js#1042)\r\n 9285 KrollContext E \tat org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1786)\r\n 9285 KrollContext E \tat org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:85)\r\n 9285 KrollContext E \tat org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1701)\r\n 9285 KrollContext E \tat script(file:///android_asset/Resources/app.js:1042)\r\n 9285 KrollContext E \tat org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\r\n 9285 KrollContext E \tat org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\r\n 9285 KrollContext E \tat org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\r\n 9285 KrollContext E \tat org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3177)\r\n 9285 KrollContext E \tat org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175)\r\n 9285 KrollContext E \tat org.mozilla.javascript.Context.evaluateReader(Context.java:1142)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext$DefaultEvaluator.evaluateFile(KrollContext.java:105)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.evaluateScript(KrollContext.java:306)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.handleEvalFile(KrollContext.java:318)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.kroll.KrollContext.handleMessage(KrollContext.java:217)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.TiMessageQueue.handleMessage(TiMessageQueue.java:223)\r\n 9285 KrollContext E \tat android.os.Handler.dispatchMessage(Handler.java:95)\r\n 9285 KrollContext E \tat android.os.Looper.loop(Looper.java:123)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:86)\r\n 9285 KrollContext E Caused by: java.lang.NullPointerException\r\n 9285 KrollContext E \tat java.net.URI$Helper.isValidDomainName(URI.java:631)\r\n 9285 KrollContext E \tat java.net.URI$Helper.isValidHost(URI.java:595)\r\n 9285 KrollContext E \tat java.net.URI$Helper.parseAuthority(URI.java:544)\r\n 9285 KrollContext E \tat java.net.URI$Helper.parseURI(URI.java:404)\r\n 9285 KrollContext E \tat java.net.URI$Helper.access$100(URI.java:302)\r\n 9285 KrollContext E \tat java.net.URI.(URI.java:87)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.util.TiUrl.absoluteUrl(TiUrl.java:251)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.util.TiUrl.resolve(TiUrl.java:195)\r\n 9285 KrollContext E \tat org.appcelerator.titanium.TiContext.resolveUrl(TiContext.java:151)\r\n 9285 KrollContext E \tat ti.modules.titanium.filesystem.FileProxy.(FileProxy.java:80)\r\n 9285 KrollContext E \tat ti.modules.titanium.filesystem.FileProxy.(FileProxy.java:49)\r\n 9285 KrollContext E \tat ti.modules.titanium.filesystem.FilesystemModule.getFile(FilesystemModule.java:69)\r\n 9285 KrollContext E \tat ti.modules.titanium.filesystem.FilesystemModuleBindingGen$8.invoke(FilesystemModuleBindingGen.java:346)\r\n 9285 KrollContext E \tat org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:51)\r\n 9285 KrollContext E \t... 15 more\r\n 9285 TiJSError E (kroll$1: app://app.js) [19,1334] ----- Titanium Javascript Runtime Error -----\r\n 9285 TiJSError E (kroll$1: app://app.js) [10,1344] - In file:///android_asset/Resources/app.js:1042,0\r\n 9285 TiJSError E (kroll$1: app://app.js) [2,1346] - Message: Wrapped java.lang.NullPointerException (file:///android_asset/Resources/app.js#1042)\r\n 9285 TiJSError E (kroll$1: app://app.js) [5,1351] - Source: null\r\n 9285 TiRootActivity I (main) [0,0] checkpoint, on root activity resume. context = org.appcelerator.titanium.TiContext@44ecf690\r\n{code}\r\n \r\n \r\n \r\n", "attachment": [], "flagged": false, "summary": "Ti.Filesystem.getFile() exception when dot-dot filesystem path notation used", "creator": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "subtasks": [], "reporter": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "environment": "Tested on:\r\n* Android 2.1 APIs, emulator\r\n* Titanium 1.6.3 (2011/05/06 13:58 7b34a7...) (works as expected)\r\n* Titanium 1.7.1 (2011/06/17 00:13 293a6d...) (generates exception)\r\n", "comment": { "comments": [ { "id": "158476", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "After a discussion with Don, it transpires that this behavior is by design, as it should not be possible to advance above the applicationDataDirectory. The ability to do this in versions below 1.7.X was allowed due to a bug.\r\n\r\nTo access other directories, the workaround at the moment is to use {{'file:///data/data/' + Ti.App.getID()}}", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2011-07-05T08:31:34.000+0000", "updated": "2011-07-05T08:31:34.000+0000" }, { "id": "422191", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket due to time passed and lack of progress in the past few years. Any further problems, please file a new ticket.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-06-16T22:25:29.000+0000", "updated": "2017-06-16T22:25:29.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }