Make WordPress Core

Opened 13 years ago

Closed 11 years ago

#8501 closed defect (bug) (invalid)

Any newlines in submitted text are converted to rn

Reported by: iquito's profile iquito Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Formatting Keywords: newlines, rnrn, escaping reporter-feedback
Focuses: Cc:


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)

#1 @mrmist
13 years ago

  • Keywords reporter-feedback added
  • Milestone set to 2.9
  • Priority changed from high to normal
  • Severity changed from major to normal

Does this still apply?

#2 @Denis-de-Bernardy
13 years ago

  • Component changed from General to Formatting
  • Owner anonymous deleted

there are 3 or 4 dups of this one... so probably.

#3 @ryan
13 years ago

  • Milestone changed from 2.9 to Future Release

#4 @dd32
11 years ago

  • Milestone Future Release deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 2.6.1 deleted

If someone finds a WordPress bug related to this, please re-open with specific steps, environment, and plugins in use.

Note: See TracTickets for help on using tickets.