Reputation: 22568
I need to pass the contents of a textarea as the source attribute of an image tag and capture all input including line breaks etc.
It looks like the only way to do this is to base 64 encode it and then urlEncode the result. (I can then unencode it all server side.)
Upvotes: 0
Views: 1565
Reputation: 943213
It looks like the only way to do this is to base 64 encode it and then urlEncode the result. (I can then unencode it all server side.)
You only need to base64 encode binary data - which a textarea won't contain.
Just use encodeURIComponent
Upvotes: 3
Reputation: 36487
urlEncode should be enough (no need for base64 as you could express line breaks as (e.g.) %0D%0A
as well) but whatever you're building sounds quite vulnerable to cross site scripting exploits.
Upvotes: 0