Browse Source

Fix the http_accept header recognition & "webpro" term

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23214 44c647ce-9c0f-0410-b52a-842ac1e357ba
interakting 15 years ago
parent
commit
52e4579efe

+ 8 - 4
library/Zend/Http/UserAgent/Mobile.php

@@ -54,7 +54,7 @@ class Zend_Http_UserAgent_Mobile extends Zend_Http_UserAgent_AbstractDevice
         'palmos', 
         'elaine', 
         'windows ce', 
-        ' ppc', 
+        'icab', 
         '_mms', 
         'ahong', 
         'archos', 
@@ -151,7 +151,7 @@ class Zend_Http_UserAgent_Mobile extends Zend_Http_UserAgent_AbstractDevice
         'vodafone', 
         'vodaphone', 
         'webos', 
-        'webpro', 
+        'wml', 
         'windows phone os 7', 
         'wireless', 
         'wm5 pie', 
@@ -173,6 +173,7 @@ class Zend_Http_UserAgent_Mobile extends Zend_Http_UserAgent_AbstractDevice
         'wml', 
         'vnd.rim', 
         'vnd.wap',
+        'j2me'
     );
 
     /**
@@ -285,12 +286,15 @@ class Zend_Http_UserAgent_Mobile extends Zend_Http_UserAgent_AbstractDevice
                 return true;
             }
         }
+        
         if (isset($server['http_x_wap_profile']) || isset($server['http_profile'])) {
             return true;
         }
 
-        if (self::_matchAgentAgainstSignatures($userAgent, self::$_haTerms)) {
-            return true;
+        if (isset($server['http_accept'])) {
+            if (self::_matchAgentAgainstSignatures($server['http_accept'], self::$_haTerms)) {
+                return true;
+            }
         }
 
         if (self::userAgentStart($userAgent)) {

+ 47 - 0
tests/Zend/Http/UserAgent/AbstractDeviceTest.php

@@ -378,6 +378,53 @@ class Zend_Http_UserAgent_AbstractDeviceTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('10.00', $extract['browser_version']);
     }
 
+    public function testMatchMobileOtherHeaders()
+    {
+        
+        $userAgent = 'xxxxx';
+        $server = array(
+            'all_http' => '. opera Mini'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        $server = array(
+            'http_x_wap_profile' => 'http://device.sprintpcs.com/Sanyo/PL3100/1003QW.rdf'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        
+        $server = array(
+            'http_profile' => ''
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        
+        $server = array(
+            'http_accept' => 'midp'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        
+        $server = array(
+            'http_accept' => 'text/html, image/vnd.wap.wbmp, image/png, image/jpeg,
+image/gif, image/bmp, application/vnd.wap.wmlc,
+application/vnd.wap.xhtml+xml, application/xhtml+xml,
+application/vnd.wap.multipart.mixed, multipart/mixed,
+text/vnd.wap.wml, application/vnd.oma.dd+xml,
+text/vnd.sun.j2me.app-descriptor, application/java-archive,
+*,text/x-hdml,image/mng,image/x-mng,video/mng,video/x-mng,image/bmp,text/html'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        
+        $server = array(
+            'http_accept' => 'vnd.rim'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+        
+        $server = array(
+            'http_accept' => 'application/xhtml+xml, application/vnd.wap.xhtml+xml,
+application/x-pmd, application/vnd.phonecom.mmc-xml, audio/midi,
+audio/vnd.qcelp, application/xhtml+xml'
+        );
+        $this->assertTrue(Zend_Http_UserAgent_Mobile::match($userAgent, $server));
+    }
+
     /** 
      * examples from http://en.wikipedia.org/wiki/List_of_user_agents_for_mobile_phones
      */

+ 2 - 1
tests/Zend/Http/index.php

@@ -12,11 +12,12 @@ $config['wurflapi']['wurfl_config_file'] = dirname(__FILE__) . '/_files/Wurfl/re
 $config['terawurfl']['terawurfl_lib_dir'] = dirname(__FILE__) . '/_files/TeraWurfl_2.1.3/tera-WURFL/';
 $config['deviceatlas']['deviceatlas_lib_dir'] = dirname(__FILE__) . '/_files/DA_php_1.4.1/';
 $config['deviceatlas']['deviceatlas_data'] = dirname(__FILE__) . '/_files/DA_php_1.4.1/sample/json/20101014.json';
+/*
 $config['mobile']['features']['path']      = 'Zend/Http/UserAgent/Features/Adapter/TeraWurfl.php';
 $config['mobile']['features']['classname'] = 'Zend_Http_UserAgent_Features_Adapter_TeraWurfl';
 $config['mobile']['features']['path']      = 'Zend/Http/UserAgent/Features/Adapter/DeviceAtlas.php';
 $config['mobile']['features']['classname'] = 'Zend_Http_UserAgent_Features_Adapter_DeviceAtlas';
-
+*/
 $config['server'] = $_SERVER;
 
 if (!empty($_GET['userAgent'])) {