Click here to get back home

how can white space enter a text file?

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
how can white space enter a text file? Lawrence Krubner 06-05-2008
Get Chitika Premium
Posted by Lawrence Krubner on June 5, 2008, 6:02 pm
Please log in for more thread options

This is one of the more bizarre things I've seen in a while.

We've a function called getListOfAllDatabaseTables that does about what
you'd expect. It lives in a file called getListOfAllDatabaseTables.php.
The file is included when the function needs to be called. The function
is called when users are adding in new information. Most of the time, if
a user fills in a form to (say for instance) create a new weblog post,
the user would hit "Submit" and then the action of adding that
information to the database would occur before the next page loads
(before any HTML is sent to the user's browser).

Suddenly, yesterday, when testing the development site, I started
getting errors when adding new material "Cannot send headers, output
already started in getListOfAllDatabaseTables.php". So I open up
getListOfAllDatabaseTables.php and, sure enough, there is a single white
space that has suddenly been added to the end of the file, outside of
the closing ?> tag. I delete the white space and thus fix the problem.

I want to know who is to blame for this so I look at the files history
in Subversion. Turns out, no one has edited this file since it was first
checked in back in November.

The whole site is under Subversion. We use Springloops.com which has a
nice auto-deploy feature. No one has FTP access to the site. No one has
SSH access to the site, except root. Really, the only way a white space
could appear in that file is if someone ssh to the server, logged in as
root, opened that file, added a white space, and then closed it without
making any other change.

Which does not seem likely. There are only two people with the root
password to the server, myself, and one other programmer. Neither of us
had any reason to touch that file, nor do either of us have any memory
of touching that file yesterday.

Any other way a white space can suddenly appear at the end of a file?




Posted by Rik Wasmus on June 5, 2008, 6:17 pm
Please log in for more thread options
On Fri, 06 Jun 2008 00:02:28 +0200, Lawrence Krubner

>
> This is one of the more bizarre things I've seen in a while.
>
> We've a function called getListOfAllDatabaseTables that does about what
> you'd expect. It lives in a file called getListOfAllDatabaseTables.php.
> The file is included when the function needs to be called. The function
> is called when users are adding in new information. Most of the time, if
> a user fills in a form to (say for instance) create a new weblog post,
> the user would hit "Submit" and then the action of adding that
> information to the database would occur before the next page loads
> (before any HTML is sent to the user's browser).
>
> Suddenly, yesterday, when testing the development site, I started
> getting errors when adding new material "Cannot send headers, output
> already started in getListOfAllDatabaseTables.php". So I open up
> getListOfAllDatabaseTables.php and, sure enough, there is a single white
> space that has suddenly been added to the end of the file, outside of
> the closing ?> tag. I delete the white space and thus fix the problem.
>
> I want to know who is to blame for this so I look at the files history
> in Subversion. Turns out, no one has edited this file since it was first
> checked in back in November.
>
> The whole site is under Subversion. We use Springloops.com which has a
> nice auto-deploy feature. No one has FTP access to the site. No one has
> SSH access to the site, except root. Really, the only way a white space
> could appear in that file is if someone ssh to the server, logged in as
> root, opened that file, added a white space, and then closed it without
> making any other change.
>
> Which does not seem likely. There are only two people with the root
> password to the server, myself, and one other programmer. Neither of us
> had any reason to touch that file, nor do either of us have any memory
> of touching that file yesterday.
>
> Any other way a white space can suddenly appear at the end of a file?

That's no PHP question, but at least some process has had to do something
to the file, or the servers configuration. Usually, in these cases, it WAS
a user, just not someone willing to own up to it. I'd check the time the
file was last changed (which you probably can't get as you changed it
back), and compare them to other logs. Then again, it could just be a
simple configuration change on the server, making the problem only visible
now (output buffering and the like).

The answer to the question 'what could do that?' is actually: almost
anything. There is no way for use to tell you without full logs & root
access to your server, and even then it's probably untracable.
--
Rik Wasmus
...spamrun finished

Posted by The Natural Philosopher on June 5, 2008, 10:02 pm
Please log in for more thread options
Rik Wasmus wrote:
> On Fri, 06 Jun 2008 00:02:28 +0200, Lawrence Krubner
>
>>
>> Any other way a white space can suddenly appear at the end of a file?
>
> That's no PHP question, but at least some process has had to do
> something to the file, or the servers configuration. Usually, in these
> cases, it WAS a user, just not someone willing to own up to it. I'd
> check the time the file was last changed (which you probably can't get
> as you changed it back), and compare them to other logs. Then again, it
> could just be a simple configuration change on the server, making the
> problem only visible now (output buffering and the like).
>
> The answer to the question 'what could do that?' is actually: almost
> anything. There is no way for use to tell you without full logs & root
> access to your server, and even then it's probably untracable.


Like the time all my carefully spaced output blocks - space padded to
get everything to line up - suddenly blew up.

The 'Hairy Programmer' eventually admitted that he had run a 'replace
every three spaces by tabs' on the source code to make it small enough
as the PDP-11 was running out of disk space..


Posted by C. (http://symcbean.blogspot.c on June 6, 2008, 7:34 am
Please log in for more thread options
>
> "Cannot send headers, output
> already started in getListOfAllDatabaseTables.php".
<snip>
>
> Which does not seem likely. There are only two people with the root
> password to the server, myself, and one other programmer. Neither of us
> had any reason to touch that file, nor do either of us have any memory
> of touching that file yesterday.
>
> Any other way a white space can suddenly appear at the end of a file?

Conjecturing about what caused this is futile - it could be lots of
different things - and there's nothing substantial in your post to
base a hypothesis on.

But you can prevent the same thing from recurring **regardles of the
cause** by employing a style requirement that the closing '?>' is
omitted from include files.

C.

Similar ThreadsPosted
how to get a line of text as an array without white space? July 26, 2008, 7:49 pm
white space in select option December 27, 2005, 4:57 pm
preserving white space with DOMDocument / loadHTML May 16, 2008, 8:46 pm
How do I hide part of an image with white space? June 13, 2008, 4:40 pm
if i wanted to have the text i enter into a database be retrived formated the way i want it how could i do that November 20, 2006, 12:17 am
Re: white spaces in uploaded html file July 23, 2006, 5:07 am
upload a file without user having to browse or enter file name July 26, 2006, 11:59 am
how do I tell a browser the name of a file, for download, if the file has open space in its name? October 20, 2007, 5:32 am
regular expression space and 2 byte space August 25, 2006, 5:25 pm
Read and display Japanese text from text file August 15, 2004, 8:38 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap