Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
JulienTLD opened this issue Jan 22, 2017 · 8 comments
Closed

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

JulienTLD opened this issue Jan 22, 2017 · 8 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Milestone

Comments

@JulienTLD
Copy link

JulienTLD commented Jan 22, 2017

Hello,

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

Thanks

Julien

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
PHPMyAdmin 4.6.5.2
MySQL 5.7.17 x64

Client configuration

Windows 7
IE11

@JulienTLD JulienTLD changed the title Editing a value of result replaces \r\n by \n Editing a result replaces \r\n by \n Jan 22, 2017
@OlafvdSpek
Copy link

Why is this a problem for you?

@JulienTLD
Copy link
Author

JulienTLD commented Jan 23, 2017

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.

Thanks.

@OlafvdSpek
Copy link

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
Copy link
Author

JulienTLD commented Jan 23, 2017

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.

@JulienTLD
Copy link
Author

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 Used when we need feedback from the submitter or when the issue is a question about PMA label Jan 23, 2017
@nijel
Copy link
Contributor

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
Copy link
Contributor

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 A problem or regression with an existing feature and removed question Used when we need feedback from the submitter or when the issue is a question about PMA 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 closed this as completed in 5588045 Jan 23, 2017
@JulienTLD
Copy link
Author

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

Thank you for your fix and for the reactivity !!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants