Line in /public/index.php which strips carriage-return, newline and tabs causes problems for javascript
Expected and Actual Behavior
The following types of javascript code placed within a view will not run
- javascript comments using //
- multiple functions contained within the same script tag
This appears to be caused by the fact that carraige-return, and newline characters are stripped
The problem is caused by the following line of code on line 42 of /public/index.php
echo str_replace(["\n","\r","\t"], '', $application->handle()->getContent());
Replacing the line with the following line resolves the problem
echo $application->handle()->getContent();
There doesn't appear to be any negative side effects to doing this so far so I'm not sure why the cr/lf chars need to be stripped.
Details
- Phalcon Framework version: 3.4.1
- PHP Version: 7.1.4
- Operating System: Windows 10
- Server: Apache
- Phalcon DevTools Version: 3.2.13
This also causes problems downloading / sending files with
$this->response->setFileToSend($sourceFile, $fileName, false);
$this->response->send();
PDF files are broken, \n\r\t also removed in Textfiles, etc.
What is the reason to remove these characters in the bootstrap process?
+1 with the above, spent hours trying to figure out what I was doing wrong, i wasn't.. :(
@mikeglennshl can you please submit a pull request to rectify the behavior?
Fixed in https://github.com/phalcon/phalcon-devtools/commit/4b103c4132332488246eb7332c20b59a83b00b58