tidev / liveview

Titanium LiveTi (live preview of Titanium applications on device)
Other
7 stars 3 forks source link

fix: correctly sanitize source #124

Closed garymathews closed 5 years ago

garymathews commented 5 years ago
TEST CASE
const win = Ti.UI.createWindow({ backgroundColor: 'green' });
win.open();

//console.log();

JIRA Ticket

jasonkneen commented 5 years ago

@ewanharris this has broken my installation of liveview -- if I revert this commit it works. I get loads of errors on startup regarding a config of RESTe I'm using that's setting requestheaders -- the config fragment looks like this

Alloy.Globals.reste.config({
    errorsAsObjects: true,
    timeout: 5000,
    debug: true,
    autoValidateParams: false,
    url: Alloy.CFG.PARSE.URL,
    requestHeaders: {
        "X-Parse-Application-Id": Alloy.CFG.PARSE.APPLICATION_ID,
        "X-Parse-REST-API-Key":Alloy.CFG.PARSE.REST_API_KEY,
        "Content-Type": "application/json",
        "X-Parse-Session-Token": getSessionToken
    },

If I run this with 124 merged, I get errors like:

[INFO]  [LiveView] Error Evaluating /alloy/backbone @ Line: 2
[ERROR] SyntaxError: Unexpected identifier 'popstate'. Expected ')' to end an argument list.
[ERROR] File: /alloy/backbone
[ERROR] Line: 2
[ERROR] SourceId: <null>
[ERROR] Backtrace:
[ERROR]  undefined
[INFO]  [LiveView] Error Evaluating /alloy/CFG @ Line: 2
[ERROR] SyntaxError: Unexpected identifier 'uncaughtException'. Expected '}' to end an object literal.
[ERROR] File: /alloy/CFG
[ERROR] Line: 2
[ERROR] SourceId: <null>
[ERROR] Backtrace:
[ERROR]  undefined
[INFO]  [LiveView] Error Evaluating app.js @ Line: 2
[ERROR] TypeError: undefined is not an object (evaluating 'Alloy.CFG.PARSE.URL')
[ERROR] File: app.js
[ERROR] Line: 2
[ERROR] SourceId: <null>
[ERROR] Backtrace:
[ERROR]  undefined

If I revert 124, I don't get these and everything works.