I'm using Jsoup for sanitizing user input from a form. The form in question contains a <textarea>
that expects plain text. When the form is submitted, I clean the input with Jsoup.clean(textareaContents)
; however, since html ignores extra whitespace, Jsoup.clean()
will remove valuable whitespace characters from the input.
For example, if someone entered some lines of text in the textarea
:
hello
test
after Jsoup.clean()
, you will have:
hello test
How can you make Jsoup.clean()
preserve whitespace? I know it's designed for parsing html and this isn't html, so is there a better alternative?
` tags. I dropped your method in and all is well now (after hours spent on this over the last two days). Thanks for taking the time to post your method. – Paul Jan 11 '17 at 16:40