#22085 [Opn->Csd]: negotiateLanguage() in HTTP.php not case-insensitive

From: Date: Thu, 13 Mar 2003 21:18:30 +0000
Subject: #22085 [Opn->Csd]: negotiateLanguage() in HTTP.php not case-insensitive
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-14269@lists.php.net to get a copy of this message
ID: 22085 Updated by: mj@php.net Reported By: stanbery at miyazaki-catv dot ne dot jp -Status: Open +Status: Closed Bug Type: PEAR related Operating System: Linux 2.4.x PHP Version: 4.2.2 New Comment: This bug has been fixed in CVS and the next release will work as expected. Previous Comments: ------------------------------------------------------------------------ [2003-02-05 23:31:25] stanbery at miyazaki-catv dot ne dot jp Ok, after a bit of cluelessness (stupidly thinking that array_change_key_case() passed by ref rather than by value), I got it working. Also, apparently, mine _isn't_ version 1.15. Just grabbed version 1.15 from CVS, diff'd against what I have (in my RedHat 8.0 distro), and it ain't the same. I've grabbed 1.17 from CVS, modified it, and tested it -- works fine. Still wondering why $supported is passed by ref instead of by var. My diff: ~ > diff HTTP.mod.php HTTP.php 84d83 < $supported = array_change_key_case($supported, CASE_LOWER); 93c92 < $l = strtolower($accepted[$i]); --- > $l = $accepted[$i]; ------------------------------------------------------------------------ [2003-02-05 21:10:28] stanbery at miyazaki-catv dot ne dot jp Ok, it seems that array_change_key_case() might be of use (didn't notice it before), as well as strtolower(). Only issue now is getting array_change_key_case() to work -- doesn't do anything as I'm calling it. Oh, btw, why is $supported passed in by reference instead of by value? ------------------------------------------------------------------------ [2003-02-05 20:54:16] stanbery at miyazaki-catv dot ne dot jp Problem with negotiateLanguage() in HTTP.php: Using M$ 5.5, with "en-us" as my language (correct by RFC), and with "ja" as my secondary language (q=0.5), I ran into a page detecting my broswer as preferring Japanese. Looked at HTTP.php, checked cvs.php.net and diff'd 1.15 (which I have) with 1.17 (latest in CVS), and the only _code_ delta was with the eregi() test. I upgraded HTTP.php, then retested -- with no luck. I then read the RFC -- RFC 2068 section 3.10 states: ... Whitespace is not allowed within the tag and all tags are case-insensitive. ... So, somehow we need a case-insensitive key for $supported (not very likely, I guess). A solution would be to force all keys of $supported to lower case, then force the $accepted array to also be lower case. Over all, not very pretty. I'll see if I can come up with an easy fix -- but if someone beats me to it, that's great. =) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22085&edit=1

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