php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13938 Windows-newlines are counted twice
Submitted: 2001-11-05 16:56 UTC Modified: 2002-05-24 20:22 UTC
From: troy at leaver dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.6 OS: WinNT 4.0
Private report: No CVE-ID: None
 [2001-11-05 16:56 UTC] troy at leaver dot com
I saw some previous reports of this bug in earlier versions of PHP 4.  It's back in 4.0.6, at least on WinNT 4.0.

Here's an extremely simple sample script:

<%

	$test = "This is an improperly terminated string;

%>

This script has a total of 5 lines.  The error generated to the browser when this script is accessed is:

Parse error: parse error in d:\users\tleaver\leaver.com\htdocs\bad.php on line 9

Line 9 does not exist.  Unlike previous reports of this bug which I've seen, this bug does not depend on includes.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-05 21:43 UTC] brianlmoon@php.net
Can you check your file for newlines after the %>.  I can reproduce the error by putting 3 or 4 newlines at the end of the file after the closing tag.  Because you are in a string, it errors when it reaches EOF.
 [2001-11-09 06:32 UTC] troy at leaver dot com
There are absolutely no newlines.  In fact, at this very moment I am making changes to a web application, and am getting a parse error on line 1837 of a script which has only 1148 lines.
 [2001-11-09 06:33 UTC] troy at leaver dot com
I should have said there are no EXTRA newlines.  Of course there are newlines in the script :)
 [2001-11-09 10:06 UTC] jeroen@php.net
You don't happen to use Windows newlines (I see your OS is windows)?

Not that that _should_ matter, but it can be the source of the problem. Try to convert to unix newlines. I notice that with (n+1)/2 you get the actual line the error is on. In the long file, doesn't the error occur on line 919 by coincidence?
 [2001-11-09 10:17 UTC] troy at leaver dot com
Yes, I am using Windows, and the Windows convention is CR+LF, while I guess the Unix convention is LF only.  However, the Windows version of PHP should understand the difference, in fact version 4.0.4pl1 worked fine.  I still consider this a bug.  You are correct, the error in the script I was working on earlier this morning was very close to line 919.
 [2001-11-09 10:37 UTC] jeroen@php.net
I didn't say it wasn't a bug, I was trying to track down the problem. 

Changed summary.
(the *nix php version handles winnewlines correctly)
 [2001-11-09 10:54 UTC] troy at leaver dot com
Ok, Gotchya.  If it would help at all, I can change to Unix style with Homesite and let you know if the line is correctly identified.

Also, I'm very suprised that this has not been reported previously.  4.0.6 has been out for awhile, and I'm sure there must be some other Windows PHP users out there.  Is there any way that this has anything to do with the ISAPI dll I'm using vs cgi, or possibly the obscure web server software I'm using?  I'm using a web server called Sambar Server (www.sambar.com), which is not widely used.

I just figure somebody else would be complaining about this if it happened under IIS.
 [2001-11-10 11:56 UTC] sander@php.net
I'm always using Windows-newlines on Windows. But I never experienced this, neither with the Apache-module, nor with the CGI-executable.
 [2001-12-14 13:30 UTC] yohgaki@php.net
Could you try 4.1.0 and report the result ?
 [2001-12-14 14:11 UTC] mfischer@php.net
Originator of this BR: please make a zipped version of such a bogus behaving script for download so we can play with it.
 [2001-12-18 13:47 UTC] troy at leaver dot com
Bug is still present, behaving exactly as with 4.0.6.  Using windows-style files, line numbers are reported as

(ActualLineNumber * 2) - 1

Using Unix-style files, line numbers are reported correctly.

All you have to do to replicate the error is to create a bogus line of php code, something that will report an error, save it in CR+LF format (Windows style vs Unix LF only) and execute.

If it's really necessary for me to create a small test script and e-mail, please let me know.
 [2002-05-24 20:22 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 17:01:33 2024 UTC