Date: 12/20/00
- Next message: augustz <email protected>: "[PHP-DEV] PHP 4.0 Bug #8334 Updated: Segmentation faults on page load"
- Previous message: augustz <email protected>: "[PHP-DEV] PHP 4.0 Bug #8334 Updated: Segmentation faults on page load"
- Next in thread: Robert B. Easter: "[PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Maybe reply: Robert B. Easter: "[PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Reply: Robert B. Easter: "Re: [PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Konqueror shows odd behavior when rendering html containing carriage returns
('\r' 0x0d ^M) that are not paired with a newline ('\n' 0x0a ^J).
In a <textarea> in a <form>, text is entered that contains "\r\n" when the
user presses the Enter key to begin a new line. This input from the user
then goes to PHP's nl2br() function which replaces occurrences of '\n' with
"<br>\n". So an occurrence of "\r\n" becomes "\r<br>\n" leaving an unpaired
'\r'. I think that nl2br() should instead replace '\n' with "\n<br>" so that
"\r\n" becomes "\r\n<br>". This would keep the "\r\n" pairs together and
make Konqueror happy. Netscape has no problem with this.
Attached are two html files. One has instances "\r<br>\n" in it caused by
nl2br(), the other file has been brought into kwrite and then resaved.
Kwrite is smart enough to detect the unpaired carriage returns, which are not
normally used in a UNIX text file (a unix text file just uses a '\n' at the
end of a line, whereas MSDOS uses "\r\n"), and treats the file as an MSDOS
text file. Kwrite creates "\r\n" pairs throughout the file matching every
lone '\n' with a '\r' in front of it, and every lone '\r' that it finds with
a '\n' after it.
Konqueror does not treat "\r<br>\n" the same as "\r\n<br>" in all situations.
For instance, with unpaired carriage returns:
<a href="file.html">file</a>^M<br>
^M<br>
^M<br>Hello,
^M<br>
^M<br>there
^M<br>
^M<br>how are you?
was giving me:
file
Hello,
there
how are you?
Without the unpaired carriage returns (^M):
<a href="file.html">file</a>
<br>
<br>
<br>Hello,
<br>
<br>there
<br>
<br>how are you?
gave me:
file
Hello
there
how are you?
The <a> tag makes a difference for some reason. If you remove it or put it
at the end, then the output is the same:
^M<br>
^M<br>Hello,
^M<br>
^M<br>there
^M<br>
^M<br>how are you?
^M<br><a href="file.html">file</a>^M<br>
gave me:
Hello
there
how are you?
file
If this isn't clean enough or no one can duplicate this, I can try to explain
again or make an better example. View the attached html files in Konqueror.
The paired.html file is slightly larger after kwrite added '\r' and some '\n'
to the file to make pairs.
-- -------- Robert B. Easter reaster <email protected> --------- - CompTechNews Message Board http://www.comptechnews.com/ - - CompTechServ Tech Services http://www.comptechserv.com/ - ---------- http://www.comptechnews.com/~reaster/ ------------
- text/html attachment: Contains unpaired newlines and returns which cause rendering trouble in Konqueror
- text/html attachment: The same file as unpaired, but resaved with kwrite which recreates newline and return pairs.
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: augustz <email protected>: "[PHP-DEV] PHP 4.0 Bug #8334 Updated: Segmentation faults on page load"
- Previous message: augustz <email protected>: "[PHP-DEV] PHP 4.0 Bug #8334 Updated: Segmentation faults on page load"
- Next in thread: Robert B. Easter: "[PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Maybe reply: Robert B. Easter: "[PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Reply: Robert B. Easter: "Re: [PHP-DEV] Problem with KDE Konqueror and PHP's nl2br() in handling carriage return and newline pairs."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

