We have an email address verification process on our website. The site first generates an appropriate key as a string
It then encodes that key as a bunch of bytes
It then base64 encodes that bunch of bytes
Since this key is going to be given as a querystring value of a URL that is to be placed in an HTML email, we need to first URLEncode it then HTMLEncode the result, giving us (there's no effect of HTMLEncoding here, but I can't be bothered to rework the example)
This is then embedded in HTML that is sent as part of an email, something like:
click <a href="http://myapp/verify?key=JiRkYWN%2ByoyIhIQ%3D%3D">here</a>. Or paste <b>http://myapp/verify?key=JiRkYWN%2ByoyIhIQ%3D%3D</b> into your browser.
When the receiving user clicks on the link, the site receives the request, extracts the value of the querystring 'key' parameter, base64 decodes it, decrypts it, and does the appropriate thing in terms of the site logic.
However on occasion we have users who report that their clicking is ineffective. One such user forwarded us the email he had been sent, and on inspection the HTML had been transformed into (to put it in terms of the example above)
click <a href="http://myapp/verify?key=JiRkYWN+yoyIhIQ%3D%3D">here</a> Or paste <b>http://myapp/verify?key=JiRkYWN+yoyIhIQ%3D%3D</b> into your browser.
That is, the %2B string - but none of the other percentage encoded strings - had been converted into a plus.
So I think that there are a couple of possibilities:
I'm doing something stupid that I can't see, or
Some mail clients try to cope with the problem of people mistakenly URLEncoding plus signs by 'helpfully' converting them all back
In case of 1 - what is it? In case of 2 - what mail clients? Or, alternatively, is there a standard, known way of dealing with this kind of scenario?
Many thanks for any help