#4441 Carriage returns are added to text fields

4.2.2
wont-fix
nobody
None
Normal
2015-04-28
2014-06-06
No

To reproduce:
Go to a table with a TEXT field.
Edit it (click the pencil icon for full page edit, not inline edit) and add some new lines.
Save.

The field now has \r\n as the new lines, not \n.

This happens on Mac and Linux, both of which use solely \n as new line indicators.

Discussion

  • DisgruntledGoat

    DisgruntledGoat - 2014-06-06

    Also meant to add, since Windows does still use \r\n, maybe a good solution is to have an option specifying which format to use?

     
  • Hugues Peccatte

    Hugues Peccatte - 2014-07-14

    Hi,
    How do you see the \r\n please? Because even with a trace (see function below), I only see one character \n (ascii code 10) on Windows.
    function checkAscii() {
    var v = $('#field_2_3').val();
    for (var i = 0; i < v.length; i++) {
    console.debug(v[i] + ' = ' + v.charCodeAt(i));
    }
    return false;
    }

    Input:
    a
    b
    Output:
    a = 97

    = 10
    b = 98

    Thanks for your feedback.

     
  • DisgruntledGoat

    DisgruntledGoat - 2014-07-17

    I just some SQL queries, for example

    SELECT * FROM table WHERE textfield LIKE '%\r%';
      -- returns results
    SELECT * FROM table WHERE textfield LIKE '%\n\n%';
      -- returns no results even when there are multiple "new lines"
    

    But I haven't tested this on Windows, sorry.

     
    Last edit: DisgruntledGoat 2014-07-17
  • Marc Delisle

    Marc Delisle - 2014-09-02

    @DisgruntledGoat: I can reproduce this issue; however, in my tests, the \r\n is already present in the HTTP request that is received when saving the edit. It's possible to strip the \r at this point, but in which situation do you suggest we do it?

    The client may be on Mac or Linux; or the web server may be; or the MySQL server may be (and all variations on these three variables).

     
  • DisgruntledGoat

    DisgruntledGoat - 2014-09-05

    @Marc interesting, so is it the browser that is sending \r\n, even on Mac/Linux?

    Originally I was envisaging an option in PMA, called something like "Normalize line endings", with options "Do nothing" (i.e. use whatever the browser sends), "Normalize to \r\n", "Normalize to \n".

     
  • Marc Delisle

    Marc Delisle - 2014-09-06

    @DisgruntledGoat: yes, I traced the packet with Wireshark: Iceweasel running on Linux is sending 0D 0A (\r\n) in this case.

    What problem do you see with the storing of \r\n? At least I don't see a display problem.

     
  • DisgruntledGoat

    DisgruntledGoat - 2014-09-06

    I think the specific problem I was having was due to exporting the database into version control. Editing a field changes the line endings which screws up diffs and so on. I change one letter and suddenly the commit is dozens or hundreds of changes.

    I'm sure there are other situations where it would cause issues, but maybe it is too specific and doesn't apply to anyone else.

     
    • Marc Delisle

      Marc Delisle - 2015-04-28

      Indeed I believe that this is too specific.

       
  • Marc Delisle

    Marc Delisle - 2015-04-28
    • status: open --> wont-fix
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks