tags:

views:

26

answers:

2

This is more of a technical question than a help question. I'm not interested in knowing if I should trim() my input.

Are there any user agents (browsers) that add whitespace to text sent over HTTP? I'm wondering in some cases if trim() is necessary (aside from users adding whitespace) because I've never actually seen a browser add anything to a value it's sending (encoding changes aside).

Was there a time in the past when user agents did this?

+1  A: 

I've never seen a browser add whitespace to a value(but that doesn't mean that much), but I've seen user's do it plenty

Doon
agreed. trim the pants off it.
Ben Reisner
A: 

I also replace double-spaces with single-spaces (and do the same with double-new lines, etc) after i trim() a string where possible and the original formatting is not very important ("street x" becomes "street x")

vlad b.
apparently stackoverflow does too - however, I wouldn't remove double new lines as they might represent new paragraphs of text.
Xeoncross
That's why i said "where... the original formatting is not very important". It's a case-by-case decision. Some times you'd want to replace any number of new lines greater than two to just two, to avoid someone creating pages with nothing but a large number of new lines or br tags (or anything else.)...
vlad b.