phalcon-devtools icon indicating copy to clipboard operation
phalcon-devtools copied to clipboard

Line in /public/index.php which strips carriage-return, newline and tabs causes problems for javascript

Open eokenned opened this issue 8 years ago • 4 comments

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

eokenned avatar Nov 01 '18 15:11 eokenned

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?

jvl1v5 avatar Dec 01 '18 02:12 jvl1v5

+1 with the above, spent hours trying to figure out what I was doing wrong, i wasn't.. :(

mikeglennshl avatar Jan 28 '19 14:01 mikeglennshl

@mikeglennshl can you please submit a pull request to rectify the behavior?

CameronHall avatar Jan 28 '19 23:01 CameronHall

Fixed in https://github.com/phalcon/phalcon-devtools/commit/4b103c4132332488246eb7332c20b59a83b00b58

CameronHall avatar Jan 29 '19 22:01 CameronHall