2
0
Просмотр исходного кода

[ZF-11749] Zend_Http_UserAgent
Fixed emit of E_NOTICE when Apple device UAs without language component are encountered


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24532 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 лет назад
Родитель
Сommit
16226eddf1

+ 3 - 1
library/Zend/Http/UserAgent/AbstractDevice.php

@@ -554,7 +554,9 @@ abstract class Zend_Http_UserAgent_AbstractDevice
             if (in_array($result['compatibility_flag'], $apple_device)) {
                 $result['device']           = strtolower($result['compatibility_flag']);
                 $result['device_os_token']  = 'iPhone OS';
-                $result['browser_language'] = trim($comment[3]);
+                if (isset($comment[3])) {
+                    $result['browser_language'] = trim($comment[3]);
+                }
                 if (isset($result['others']['detail'][1])) {
                     $result['browser_version']  = $result['others']['detail'][1][2];
                 } elseif (isset($result['others']['detail']) && count($result['others']['detail'])) {

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

@@ -10098,4 +10098,14 @@ audio/vnd.qcelp, application/xhtml+xml'
         $capabilities = Zend_Http_UserAgent_AbstractDevice::extractFromUserAgent($userAgent);
         $this->assertEquals('AppleCoreMedia', $capabilities['browser_name']);        
     }
+    
+    /**
+     * @group ZF-11749
+     */
+    public function testUserAgentAppleWebKit53446WithoutLanguageShouldNotResultInNotices()
+    {
+        $userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A5313e Safari/7534.48.3';
+        $capabilities = Zend_Http_UserAgent_AbstractDevice::extractFromUserAgent($userAgent);
+        $this->assertEquals('Safari Mobile', $capabilities['browser_name']);
+    }
 }