I just found out about escaping things and started reading about how risky it would be to use $_SERVER['HTTP_HOST']because of XSS attacks.
I came up with this and wondered if I could get some feedback on my attempt.
htmlspecialchars(
filter_var( $_SERVER[ 'HTTP_HOST' ], FILTER_SANITIZE_URL ),
ENT_QUOTES, 'UTF-8'
)
Does it look good?
So much depends on how secure this single variable is, I just needed to request input.
EDIT:
I will use this to display on the entire site, including the basic hrefs bindings, action forms, etc.
source
share