Bug #66312 [NEW]: PHP code inside <script> deletes LF

From: Date: Tue, 17 Dec 2013 23:19:55 +0000
Subject: Bug #66312 [NEW]: PHP code inside <script> deletes LF
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183380@lists.php.net to get a copy of this message
From: danielslcosta at gmail dot com Operating system: Windows 7 PHP version: 5.5.7 Package: *General Issues Bug Type: Bug Bug description:PHP code inside <script> deletes LF Description: ------------ To prevent some editors showing errors in Javascript code with PHP code inside it, I comment the lines with PHP code. When you run the code, the alert and </script> goes one line up, and become commented. It seems it's "eating" the Line Feeds. Tested with LF and CRLF, both in Windows 7/PHP 5.5.7 TS and CentOS 6.4 with PHP 5.5.5. If you put a space or any other character after the closing tag ?> it works. Test script: --------------- <script type='text/javascript'> //<?php if (1) { ?> alert('test'); //<?php } ?> </script> <script type='text/javascript'> //<?php if (1) { ?>/ alert('test'); //<?php } ?>/ </script> Expected result: ---------------- The JS alert box should pop and the resulting HTML should be: <script type='text/javascript'> // alert('test'); // </script> <script type='text/javascript'> /// alert('test'); /// </script> Actual result: -------------- The 'alert' and '</script>' are commented <script type='text/javascript'> // alert('test'); //</script> <script type='text/javascript'> /// alert('test'); /// </script> -- Edit bug report at https://bugs.php.net/bug.php?id=66312&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=66312&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=66312&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=66312&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=66312&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=66312&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=66312&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=66312&r=needscript Try newer version: https://bugs.php.net/fix.php?id=66312&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=66312&r=support Expected behavior: https://bugs.php.net/fix.php?id=66312&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=66312&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=66312&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=66312&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=66312&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=66312&r=dst IIS Stability: https://bugs.php.net/fix.php?id=66312&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=66312&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=66312&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=66312&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=66312&r=mysqlcfg

« previous php.bugs (#183380) next »