php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22085 negotiateLanguage() in HTTP.php not case-insensitive
Submitted: 2003-02-05 20:54 UTC Modified: 2003-03-13 15:18 UTC
From: stanbery at miyazaki-catv dot ne dot jp Assigned:
Status: Closed Package: PEAR related
PHP Version: 4.2.2 OS: Linux 2.4.x
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: stanbery at miyazaki-catv dot ne dot jp
New email:
PHP Version: OS:

 

 [2003-02-05 20:54 UTC] 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. =)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-05 21:10 UTC] 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 23:31 UTC] 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-03-13 15:18 UTC] mj@php.net
This bug has been fixed in CVS and the next release will work as expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 18:01:32 2025 UTC