Any newlines in submitted text are converted to rn
|Reported by:||iquito||Owned by:|
|Component:||Formatting||Keywords:||newlines, rnrn, escaping reporter-feedback|
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 .
Change History (4)
- Keywords reporter-feedback added
- Milestone set to 2.9
- Priority changed from high to normal
- Severity changed from major to normal
- Component changed from General to Formatting
- Owner anonymous deleted