<textarea> \r\n count as just \n
Reported by
david.pr...@gmail.com,
Aug 29
|
|||
Issue descriptionUserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.57 Safari/537.36 Steps to reproduce the problem: Even when you explictly put "\r\n" into a <textarea>, it is recognized as just "\n". So a text like "a\r\nb" counts 3 bytes instead of 4 bytes. I agree that "\n" is better because it is more easy to end-user understand "why a breakline uses 1 character instead of 2", but the problem is on form submit, because it sends 4 bytes instead of 3. https://jsfiddle.net/xpvt214o/703206/ <form action="" method="POST"> <textarea name="textarea"></textarea> <div class="bytes"></div> <input type="submit"> </form> // with jQuery 3.1.1 (but it doesn't changes the behavior) const textarea = $('textarea'); textarea.val("a\r\nb"); // putting 4 bytes into textarea $('.bytes').text(textarea.val().length + ' bytes?'); // 3 bytes? When you do submit the form, the param is sent like: textarea=a%0D%0Ab (in other terms: textarea=a\r\nb) What is the expected behavior? Submit 3 bytes (a\nb) instead of 4 (a\r\nb). What went wrong? Because this behavior, if on next page you compare the previous input with the current form value via JS for ie, it will be false. Because the previously transfered data is 4 bytes, while the form value is just 3 (because it doesn't counts \r). Did this work before? N/A Chrome version: 69.0.3497.57 Channel: n/a OS Version: 10.0 Flash Version: Chrome, FF and Edge have the same behavior.
,
Aug 30
Able to reproduce the issue on chrome reported version# 69.0.3497.57, latest beta# 69.0.3497.72 and on latest chrome# 70.0.3537.0 using Windows-10, Mac 10.12.6 and Ubuntu 14.04. As this issue is seen from M-60(60.0.3112.0), hence considering this issue as Non-Regression and marking it as Untriaged. Thanks!
,
Sep 3
The behavior matches to the HTML standard perfectly, and all major browsers have this behavior. We can't change the behavior. The specification link: https://html.spec.whatwg.org/multipage/form-elements.html#the-textarea-element:concept-textarea-raw-value-8 |
|||
►
Sign in to add a comment |
|||
Comment 1 by vamshi.kommuri@chromium.org
, Aug 30