This is more of a theory question, than practical. Some basic input gets passed to my server. In general, I encode it, but I do not double encode it.
I was thinking about any problems that could arise from that decision. One, is if someone enters the following two strings on a form on my site:
Apples & Bananas
Apples & Bananas
These would respectively be stored as, due to single encoding:
Apples & Bananas
Apples & Bananas
If I were to output them, I would decode them before doing so. The user would then see:
Apples & Bananas
Apples & Bananas
The source would be:
Apples & Bananas
Apples & Bananas
Therefore, I will have lost some of the structure of the submission, since an entity would essentially be equal to it's encoded version, upon submission.
My instinct is that they should always be double encoded, but I would be curious to hear another opinion on this.