{"action":"created","issue":{"url":"https://api.github.com/repos/jsoverson/preprocess/issues/46","labels_url":"https://api.github.com/repos/jsoverson/preprocess/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/jsoverson/preprocess/issues/46/comments","events_url":"https://api.github.com/repos/jsoverson/preprocess/issues/46/events","html_url":"https://github.com/jsoverson/preprocess/issues/46","id":54053308,"number":46,"title":"In getTestTemplate() empty template is evaluated as true","user":{"login":"lupugabriel1","id":3968053,"avatar_url":"https://avatars.githubusercontent.com/u/3968053?v=3","gravatar_id":"","url":"https://api.github.com/users/lupugabriel1","html_url":"https://github.com/lupugabriel1","followers_url":"https://api.github.com/users/lupugabriel1/followers","following_url":"https://api.github.com/users/lupugabriel1/following{/other_user}","gists_url":"https://api.github.com/users/lupugabriel1/gists{/gist_id}","starred_url":"https://api.github.com/users/lupugabriel1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lupugabriel1/subscriptions","organizations_url":"https://api.github.com/users/lupugabriel1/orgs","repos_url":"https://api.github.com/users/lupugabriel1/repos","events_url":"https://api.github.com/users/lupugabriel1/events{/privacy}","received_events_url":"https://api.github.com/users/lupugabriel1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-12T13:29:06Z","updated_at":"2015-04-23T20:25:49Z","closed_at":"2015-02-06T19:26:03Z","body":"In preprocess.js the following method gets test = \"%0D\" (newline)\r\n```javascript\r\nfunction getTestTemplate(test) {\r\n  /*jshint evil:true*/\r\n  test = test || 'true==true';\r\n\r\n  // force single equals replacement\r\n  test = test.replace(/([^=])=([^=])/g, '$1==$2');\r\n\r\n  return new Function(\"context\", \"with (context||{}){ return ( \" + test + \" ) }\");\r\n}\r\n```\r\nthis is causing test to be evaluated as true because it's a newline, and the \r\n```javascript\r\nnew Function(\"context\", \"with (context||{}){ return ( \" + test + \" ) }\");\r\n```\r\nbreaks with \"SyntaxError: Unexpected token )\".\r\nThis happens only under Windows (8.1 x64), on MAC it runs fine.\r\n\r\nFull stack \r\n```\r\nRunning \"preprocess:ironclad\" (preprocess) task\r\nWarning: Unexpected token ) Use --force to continue.\r\nSyntaxError: Unexpected token )\r\n    at Object.Function (<anonymous>)\r\n    at getTestTemplate (D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:123:10)\r\n    at testPasses (D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:127:16)\r\n    at D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:78:12\r\n    at String.replace (native)\r\n    at preprocess (D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:77:11)\r\n    at D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:68:22\r\n    at String.replace (native)\r\n    at Object.preprocess (D:\\ironclad\\node_modules\\grunt-preprocess\\node_modules\\preprocess\\lib\\preprocess.js:58:11)\r\n    at D:\\ironclad\\node_modules\\grunt-preprocess\\tasks\\preprocess.js:58:36\r\n```\r\n\r\nAlso, the following test is failing:\r\n```\r\nRunning \"nodeunit:preprocess\" (nodeunit) task\r\nTesting preprocess_test.js..........F......\r\n>> preprocess - include files\r\n>> Message: Should include files and indent if ending with a newline\r\n>> Error: 'a!foobar!\\r\\n c' == 'a!foobar!\\n c'\r\n>> at Object.exports.preprocess.include files (test\\preprocess_test.js:443:10)\r\n>> at Object.exports.preprocess.setUp (test\\preprocess_test.js:35:5)\r\n\r\nWarning: 1/76 assertions failed (26ms) Use --force to continue.\r\n\r\nAborted due to warnings.\r\n```"},"comment":{"url":"https://api.github.com/repos/jsoverson/preprocess/issues/comments/95710205","html_url":"https://github.com/jsoverson/preprocess/issues/46#issuecomment-95710205","issue_url":"https://api.github.com/repos/jsoverson/preprocess/issues/46","id":95710205,"user":{"login":"ma7hatter","id":575694,"avatar_url":"https://avatars.githubusercontent.com/u/575694?v=3","gravatar_id":"","url":"https://api.github.com/users/ma7hatter","html_url":"https://github.com/ma7hatter","followers_url":"https://api.github.com/users/ma7hatter/followers","following_url":"https://api.github.com/users/ma7hatter/following{/other_user}","gists_url":"https://api.github.com/users/ma7hatter/gists{/gist_id}","starred_url":"https://api.github.com/users/ma7hatter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ma7hatter/subscriptions","organizations_url":"https://api.github.com/users/ma7hatter/orgs","repos_url":"https://api.github.com/users/ma7hatter/repos","events_url":"https://api.github.com/users/ma7hatter/events{/privacy}","received_events_url":"https://api.github.com/users/ma7hatter/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T20:25:48Z","updated_at":"2015-04-23T20:25:48Z","body":"I thought I had the same issue.  It turned out I had a copy-paste issue with '// ifdef etc... -->' where I had left on an html tag on the end.  It would be nice to have a little better logging info to find these types of syntax errors, as all it says is the aforementioned 'SyntaxError: Unexpected token )'.  Hope this is helpful."}}