[wp-trac] [WordPress Trac] #8501: Any newlines in submitted text are
converted to rn
WordPress Trac
wp-trac at lists.automattic.com
Fri Dec 5 21:44:12 GMT 2008
#8501: Any newlines in submitted text are converted to rn
---------------------+------------------------------------------------------
Reporter: iquito | Owner: anonymous
Type: defect | Status: new
Priority: high | Milestone:
Component: General | Version: 2.6.1
Severity: major | Keywords: newlines, rnrn, escaping
---------------------+------------------------------------------------------
Since about June/July 2008 I noticed that any submitted content with
wordpress on my server results in all newlines being converted to "rn" -
it does not matter if a comment is submitted or a blog article is written.
I removed all plugins and upgraded to 2.6.5 to have an absolutely clean
installation, I also turned off magic quotes in case this could have
something to do with it - yet the problem still occured.
After a lot of wordpress code digging, I found out where exactly the
problem starts - in /wp-includes/functions.php in the function
"add_magic_quotes" in the line "$array[$k] = $wpdb->escape( $v );" ,
called from wp-settings.php on lines 464 to 467.
$wpdb->escape should only perform an addslashes on $v, yet "$array[$k] =
$wpdb->escape( $v );" and "$array[$k] = addslashes( $v );" do not produce
the same results - $wpdb->escape converts every \n to an actually visible
\n and basically eradicates the newline (instead of escaping it), that's
why \r\n ends up becoming rn when a stripslashes is performed later.
$wpdb->escape behaves the same way when called on the explicit $_POST
variable in global context.
I cannot explain the reason for this behaviour, it does not really make
sense - the most logical thing I can think of is that it's a PHP bug, the
bug appears with Wordpress 2.4, 2.5 and also 2.6.5 (all versions I have
tried), the version I am using now. I use PHP 5.2.6 (on debian), and I
think I started to notice the problem some time after the upgrade from
5.2.5 to 5.2.6 (I'm not an extremely active blogger, so it took some time
to notice).
I will upgrade to PHP 5.2.7 soon, yet still this is maybe a problem which
should be looked at, especially if it's not fixed in 5.2.7 .
--
Ticket URL: <http://trac.wordpress.org/ticket/8501>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list