0

I'm maintaining this website that accepts multi-line inputs from user and sends the data via JSON. line break \n are decoded and encoded properly but somehow the \r chars are not accepted on the server side and I have the feeling I would need to escape them prior to sending them over. Before making the fix, I want to try to reproduce the issue but I can't find a way to do it !!!!

Do you have any recommendations?

EDIT after more investigation, it turns out that the issue is in IE only ( as in the \r chars get added when copying/pasting to the text input). Hijacking the text area did not change anything in FF or chrome and doing a data.description.replace("\r","") did not solve the issue either. Still poking around.

2
  • Do you have any code that you could post? Commented Aug 29, 2012 at 16:03
  • 1
    The way I've always handled that kind of thing is to keep the newline characters, but just remove all of the carriage-return (\r) characters. This might work for you, depending on what you want to do with the data. Commented Aug 29, 2012 at 16:04

2 Answers 2

2

if you just want to reproduce the error, just add some js to populate the textarea:

document.getElementById('textarea-id').value = 'test\r\ntest';

Sign up to request clarification or add additional context in comments.

Comments

0

Chrome's Developer Tool's Javascript Console lets you send JSON to your server using friendly jQuery/MooTools/Protoype syntax

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.