douye1940 2012-09-27 13:02
浏览 296
已采纳

为什么IE用户代理字符串在表单POST上发生了如此显着的变化?

I'm running a vote system. Sessions keys are partially generated using a hash of the browser useragent string. Some users are encountering errors because of weird useragent string changes as seen below by a page trace.

The useragent is being detected in the following manor in PHP at the very beginning of each page load.

function useragent()
{
    static $user_agent = null;
    if($user_agent === null)
    {
        $user_agent = getenv('HTTP_USER_AGENT');
        if(empty($user_agent) === true)
        {
            $user_agent = $_SERVER['HTTP_USER_AGENT'];
        } 
    }
    return $user_agent;
}

Page action trace as below.

[2012-09-27 13:20:50] => Array
(
   [uri] => /start
   [ua] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Sky Broadband; DS_desktopsmiley; GTB7.4; chromeframe/21.0.1180.89; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; playbrytetoolbar_playbryte; AskTB5.6; 789905664603; lib/6.02324)
)

[2012-09-27 13:20:50] => Array
(
   [uri] => /nominees
   [ua] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Sky Broadband; DS_desktopsmiley; GTB7.4; chromeframe/21.0.1180.89; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; playbrytetoolbar_playbryte; AskTB5.6; 789905664603; lib/6.02324)
)

[2012-09-27 13:21:10] => Array
(
   [uri] => /nominees-save
   [post] => Array
       (
           [category] => talent_show
           [talent_show] => 5
       )
   [ua] => Mozilla/5.0 (Windows NT 6.0; chromeframe/21.0.1180.89) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
)
[2012-09-27 13:21:10] => Array
(
   [uri] => /vote-error
   [ua] => Mozilla/5.0 (Windows NT 6.0; chromeframe/21.0.1180.89) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1
)

[2012-09-27 13:21:16] => Array
(
   [uri] => /vote-start
   [ua] => Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Sky Broadband; DS_desktopsmiley; GTB7.4; chromeframe/21.0.1180.89; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30618; playbrytetoolbar_playbryte; AskTB5.6; 789905664603; lib/6.02324)
)

There are three things I notice. 1) this person has a crap load of toolbars installed. 2) Chromeframe is installed. 3) the MSIE exists on normal pages but not on a POST request and the subsequent request.

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

is added to the HTML and returned headers. Is chromeframe the responsible party here? If so why would chromeframe be hijacking POST request headers like this? If it is not chromeframe any ideas as to why?

  • 写回答

2条回答 默认 最新

  • dongwusang0314 2012-09-27 13:22
    关注

    My guess would definitely be ChromeFrame. There are probably numerous reasons as to why the user agent string is being augmented by it. Here are a few I could guess at (these all hinge on the fact that ChromeFrame probably steps in only when it thinks it is required):

    1. ChromeFrame - when enabled - has no knowledge or access to the original browsers user agent string, And so generates it's own.

    2. It could do it to aid development server-side.

    3. ChromeFrame is an entirely different user agent, so therefore it could easily be argued that it should report differently to the server-side. (especially changing from Mozilla 4.0 to 5.0)

    http://www.chromium.org/developers/how-tos/chrome-frame-getting-started#TOC-Detecting-Google-Chrome-Frame-and-Prompting-to-Install

    Basically the user agent string is not reliable. You should find some other means.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊