ZF-12133: Zend_Locale::getQuestion() Returning Bad 'noexpr' and 'yesexpr' expressions

Description

The following code


$locale = new Zend_Locale('fr_FR');
print_r($locale->getQuestion());

will return


Array
(
    [yes] => oui
    [no] => non
    [yesarray] => Array
        (
            [0] => oui
            [1] => o
        )

    [noarray] => Array
        (
            [0] => non
            [1] => n
        )

    [yesexpr] => ^([oO]([uU][iI])?)|([oO]?)
    [noexpr] => ^([nN]([oO][nN])?)|([nN]?)
)

Then


preg_match('/^([oO]([uU][iI])?)|([oO]?)/', 'any string even an empty one')

will always be 1 because of the :

[yesexpr] => ^(oO?){color:red}|([oO]?){color}

Then I think that a correction for this issue would be changing these lines in Zend/Locale.php :


if ($one === false) {
    $regex .= ')';
}

$regex .= '?)';

by


if ($one === false) {
    $regex .= ')?)';
} else {
    $regex .= ')';
}

The bug is independant of the locale.

Comments

No comments to display