Ver código fonte

ZF-5855: Apply patch from Mike Willbanks to strip helper attribute in Captcha output

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16138 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 anos atrás
pai
commit
20eb01eb61

+ 18 - 0
library/Zend/Form/Element/Captcha.php

@@ -126,6 +126,24 @@ class Zend_Form_Element_Captcha extends Zend_Form_Element_Xhtml
     }    
 
     /**
+     * Return all attributes
+     *
+     * @return array
+     */
+    public function getAttribs()
+    {
+        $attribs = get_object_vars($this);
+        unset($attribs['helper']);
+        foreach ($attribs as $key => $value) {
+            if ('_' == substr($key, 0, 1)) {
+                unset($attribs[$key]);
+            }
+        }
+
+        return $attribs;
+    }
+
+    /**
      * Set options
      *
      * Overrides to allow passing captcha options

+ 9 - 0
tests/Zend/Form/Element/CaptchaTest.php

@@ -153,6 +153,15 @@ class Zend_Form_Element_CaptchaTest extends PHPUnit_Framework_TestCase
         $this->assertTrue(array_key_exists('Zend_Form_Decorator_HtmlTag', $decorators), 'Missing HtmlTag decorator' . var_export(array_keys($decorators), 1));
         $this->assertTrue(array_key_exists('Zend_Form_Decorator_Label', $decorators), 'Missing Label decorator' . var_export(array_keys($decorators), 1));
     }
+
+    /**
+     * @group ZF-5855
+     */
+    public function testHelperDoesNotShowUpInAttribs()
+    {
+        require_once 'Zend/View.php';
+        $this->assertFalse(array_key_exists('helper', $this->element->getAttribs()));
+    }
 }
 
 class Zend_Form_Element_CaptchaTest_SessionContainer