Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Safari http_accept_language and PHP: strange...

Safari http_accept_language and PHP: strange...
Thread Tools
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status: Offline
Reply With Quote
Jan 17, 2005, 04:10 AM
 
I'm trying to solve a language redirect problem: an index.php that uses http://sourceforge.net/projects/l-redirector/. This works beautifully in Mozilla, Firefox, IE, IE5 win, IE6 win, iCab, Opera.
It chokes in Safari and OmniWeb and outputs "too many redirects", because the page is redirected to itself.

Now I've been testing a little and have found something interesting: the HTTP_ACCEPT_LANGUAGE header is handled differently in Safari (I assume Webcore to be at fault, as OmniWeb also shows "too many redirects").

Here's the output from non-Webcore-based browsers:
HTTP ACCEPT LANGUAGE: en,ja;q=0.93,fr;q=0.86
language after str to lower: en
language after sub str: en
language after str to lower: ja
language after sub str: ja
language after str to lower: fr
language after sub str: fr

Here's the output from Safari:
HTTP ACCEPT LANGUAGE: en, ja;q=0.92, ja-jp;q=0.96, fr;q=0.88, de-de;q=0.85, de;q=0.81
language: en, ja, ja-jp, fr, de-de, de
language after str to lower: en
language after sub str: en
language after str to lower: ja
language after sub str: j
language after str to lower: ja-jp
language after sub str: j
language after str to lower: fr
language after sub str: f
language after str to lower: de-de
language after sub str: d

Notice how PHP outputs only one character after applying "substr ($language, 0, 2);"! This is very strange, as the string the substring command is applied to looks very much the same to me in Firefox and Safari, e.g. Opera/Mozillas/IEs: "fr" -> "fr" whereas Safari: "fr" -> "f".

As PHP is executed on the server, I don't think it has anything to do with Cache, Cookies or somesuch.

Anyone more knowledgeable than me know what is happening here? Thanks!
MBP 15" 2.33GHz C2D 3GB 2*23" ACD
     
Mac Elite
Join Date: Jul 2001
Location: Switzerland
Status: Offline
Reply With Quote
Jan 17, 2005, 05:48 AM
 
Found it: the PHP script was not prepared for the space character in WebCore's HTTP_ACCEPT_LANGUAGE between one definition and the next (because every other browser does not send it that way?).
MBP 15" 2.33GHz C2D 3GB 2*23" ACD
     
Senior User
Join Date: Nov 2001
Location: State of Denial
Status: Offline
Reply With Quote
Jan 17, 2005, 07:45 AM
 
Yeah; AFAIK spaces are allowed like that. I think it'd be better to not use substr and use a regex instead.
[Wevah setPostCount:[Wevah postCount] + 1];
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:35 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2