HTTP::negotiateLanguage() TLD extraction broken

From: Date: Sun, 26 Jan 2003 19:59:03 +0000
Subject: HTTP::negotiateLanguage() TLD extraction broken
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-12760@lists.php.net to get a copy of this message
Looking at the current code of HTTP::negotiateLanguage() I see, that top level domain (TLD) extraction is completelly wrong: /* Check for a valid language code in the top-level domain of * the client's host address. */ if (isset($HTTP_SERVER_VARS['REMOTE_HOST']) && ereg("\.[^\.]+$", $HTTP_SERVER_VARS['REMOTE_HOST'], $arr)) { $lang = strtolower($arr[1]); if (!empty($supported[$lang])) { return $lang; } } Trying ereg("\.[^\.]+$", 'maxim.platon.sk', $arr); var_dump($arr); I got array(10) { [0]=> string(3) ".sk" [1]=> bool(false) [2]=> bool(false) [3]=> bool(false) [4]=> bool(false) [5]=> bool(false) [6]=> bool(false) [7]=> bool(false) [8]=> bool(false) [9]=> bool(false) } Returned strtolower($arr[1]) is whatever, but not the correct language/TLD code. I can provide fix for this, but I already posted patch for HTTP::negotiateLanguage() and it was not even discussed. Is there such interest? -- _/| Ondrej Jombik - nepto@php.net - http://www.nepto.sk - OJ812-RIPE <_ \ Platon SDG - open source software development - http://platon.sk `\| Ako sa do hory vola, tak sa zhori traktor! (c) 1999 Rattkin/MFF '`

« previous php.pear.dev (#12760) next »