Editing a result replaces \r\n by \n #12918

JulienTLD opened this Issue Jan 22, 2017 · 8 comments


None yet

3 participants

JulienTLD commented Jan 22, 2017 edited


I have observed that when fast editing (AJAX ?) a text result (mediumtext for example) of a select SQL request, the \r\n (CRLF) characters are replaced by simple \n (LF). It's a problem for me.

The PHP_EOL constant should be used instead of a \n



Steps to reproduce

  1. Run a select request
  2. Double click on the field of one result row
  3. Modify the string
  4. Press enter to validate

Server configuration

Windows Server 2012
PHP 7.1.1 x64 NTS
MySQL 5.7.17 x64

Client configuration

Windows 7

@JulienTLD JulienTLD changed the title from Editing a value of result replaces \r\n by \n to Editing a result replaces \r\n by \n Jan 22, 2017

Why is this a problem for you?

JulienTLD commented Jan 23, 2017 edited

Because, in some of my PHP scripts, I do treatments on carriage returns and line feed (replace, split, preg...) and it doesn't work anymore for datas which have been edited with PMA.

Since PHP 5.x, PHP offers the right way to manipulate new lines universally on all architectures (the constant PHP_EOL). It's strange that a famous application like PHPMyAdmin doesn't uses it !

PHPMyAdmin doesn't have to force the use of \n in my point of view. It should use either the server configuration (affected by PHP in the constant) or at least the client configuration (\r\n for Windows user agents, \n for Linux etc.).

Hope my request will be taken into account.



Wouldn't it be better to have your code support both EOL styles?
Using the style of the client wouldn't work, suppose you were using pMA from a Linux client.. ;)
Using the style of the server might not be appropriate either, I frequently use \n on Windows.

JulienTLD commented Jan 23, 2017 edited

I use only \r\n (with the PHP_EOL constant) in all my code so no, I will not modify and complex all my code just to satisfy PMA editing compatibility. It's would not a reflexive solution.

In my case, \r\n treatments are only done on the private dashboard part and we control the clients type.
On the public part, we just do nl2br() which supports both \r\n and \n
But, on my advise, it's would be better to use the server configuration in priority.

Never used only \n on Windows. It is not the default usage. If rare users want to use \n on Windows, ok free to them, but by default, PMA shoud use the default PHP_EOL value for majority of users. It is a matter of common sense and the good practice I think.


Perhaps, you could also offer a new option variable in the PMA config file to let the user choose the new line representation.

@nijel nijel added the question label Jan 23, 2017
nijel commented Jan 23, 2017

phpMyAdmin just uses data you've sent with your browser and stores them in the database. So you can as well claim that it is bug in your browser that it silently changed the textarea content.

Anyway from phpMyAdmin point of view, I really don't see reason for rewriting the user posted content before passing it to the database.

nijel commented Jan 23, 2017

I've looked a bit deeper and the HTML specification is a bit inconsistent in this:

  • the value edited in the browser and accessible by javascript uses \n
  • the form submitted value transforms this to \r\n

As result phpMyAdmin is inconsistent whether you use inline editor or full page editor...

@nijel nijel added bug and removed question labels Jan 23, 2017
@nijel nijel self-assigned this Jan 23, 2017
@nijel nijel added this to the 4.7.0 milestone Jan 23, 2017
@nijel nijel added a commit that closed this issue Jan 23, 2017
@nijel nijel Always use \r\n as newline when editing fields
Convert \n to \r\n during inline editing to be consistent with form submitted

The internal browser representation has to be just \n while form submitted
value \r\n, see specification:


Fixes #12918

Signed-off-by: Michal Čihař <michal@cihar.com>
@nijel nijel closed this in 5588045 Jan 23, 2017

I was persuaded that the "conversion" was done by phpMyAdmin, not by the browser.

Thank you for your fix and for the reactivity !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment