Simple PHP XSS / Urlencode Question -
i have email address param email addresses passed un-encoded so:
http://domain/script?email=test+test@gmail.com
what php escaping/encoding let me safely display email address on input field on page?
everything tried causes encoded chars show instead of user-friendly email address (i.e. test%2btest%40test.com)
update - here's i've tried:
going ?email=test+test@gmail.com to:
urlencode($_get['email']) = test+test%40test.com (@ sign encoded) htmlspecialchars($_get['email']) = test test@test.com (lost +) htmlspecialchars(urlencode($_get['email']) = test+test%40test.com (@ sign encoded)
recall i'm trying take unencoded url email param , safely output value of input field while keeping plus signs intact.
maybe should try this?
str_replace("%40", "@", htmlspecialchars(urlencode($_get['email'])))
if want safely output in value of input field, need htmlencode first htmlspecialchars.
example :
<input type="email" name="email" value="<?php echo htmlspecialchars($_get['email']); ?>"
note : if aren't using double quote around output, need apply more escaping. this page explains all.
Comments
Post a Comment