cgsmith / zf1-recaptcha-2

Zend Framework 1 integration for Google reCAPTCHA version 2.0
MIT License
9 stars 11 forks source link

Zend_Form_Element::filterName issue #17

Open JonTJ opened 7 years ago

JonTJ commented 7 years ago

Hi there

Im having trouble with hydration - isValid always returns false as it thinks the value is empty. Zend_Form_Element::filterName() filters out '-' characters when setting the element name, obviously this is an issue as Google renders the element on the page with the '-' characters (g-recaptcha-response becomes grecaptcharesponse). Is there a known work around for this short of extending the Zend_Form_Element class to include the '-' character in the list of allowed name characters?

Many thanks! Jon

JonTJ commented 7 years ago

adding the following method to ..\Form\Element\Recaptcha fixes this issue:

public function filterName($value, $allowBrackets = false) { $charset = '^a-zA-Z0-9\-_\x7f-\xff'; if ($allowBrackets) { $charset .= '\[\]'; } return preg_replace('/[' . $charset . ']/', '', (string) $value); }

cgsmith commented 7 years ago

Hi @JonTJ - thanks for the find and fix. Would you like to make a pull request? I can push this out once that is done.