yoshi
yoshi

Reputation: 1315

How to validate HTTP_ACCEPT_LANGUAGE?

Since the script gets $_SERVER['HTTP_ACCEPT_LANGUAGE'] from the visitor it could be anything. So how can I validate it? What is acceptable?

To get the first language inside the string I use:

substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2)

Upvotes: 3

Views: 425

Answers (1)

Alan Mattano
Alan Mattano

Reputation: 880

For example

$user_lang= split(",",$_SERVER["HTTP_ACCEPT_LANGUAGE"]);
$language = $user_lang[0];

// header injection.
if(stripos($language, 'Content-Type') !== FALSE ) { exit; }

Upvotes: 1

Related Questions