[wp-trac] Re: [WordPress Trac] #4005: php-gettext's plural forms
parsing is broken for nplurals>2
WordPress Trac
wp-trac at lists.automattic.com
Thu Mar 29 13:03:58 GMT 2007
#4005: php-gettext's plural forms parsing is broken for nplurals>2
------------------------------+---------------------------------------------
Reporter: moeffju | Owner: ryan
Type: defect | Status: new
Priority: high | Milestone: 2.2
Component: i18n | Version: 2.1.2
Severity: normal | Resolution:
Keywords: has-patch commit |
------------------------------+---------------------------------------------
Comment (by nbachiyski):
I am not sure if it is worth it to sanitize the string. There is great
chance that every filtering can be compromised and cheated. Also, if
somebody wants to distribute harmful code, there are surely easier ways to
to it.
A side note - I think we could speed up {{{select_string}}} a lot. We
could just the first time compile the code using {{{create_function}}} and
then just call it to get the plural index. Something like (I haven't
prepared the real patch yet):
{{{
$s = str_replace('n', '$n', $string);
$this->choose_plural_string = create_function('$n', 'return '.$s);
}}}
After that on every call of {{{select_string}}} we just return
{{{$this->choose_plural_string($n)}}}.
My trivial tests show that this approach is between 5 and 10 times faster.
Unfortunately there aren't many plural strings, so it won't be noticeable
:-)
--
Ticket URL: <http://trac.wordpress.org/ticket/4005#comment:13>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list