Re: [PHPLIB-DEV] oohforms bad escape sequence From: Kristian Köhntopp (kk <email protected>)
Date: 10/26/99

Massimiliano Masserelli wrote:
> On Tue, Oct 26, 1999 at 11:56:25AM +0200, ak <email protected> wrote:
> > if (ereg("([a-zA-Z_]+)[([0-9]+)]", $el["name"], $regs)) {
> > because [ and ] need no escape.
>
> [ and ] do need escape in regex when they are intended to be matched
> literally. PHP3 manual is not too clear on this issue, and at the moment
> I don't have the time to go through php3 sources.

In oohforms.inc:243, we have

    // translate names like $foo[int] to $foo{int} so that they can cause no
    // harm in $this->elements
    # Original match
    # if (preg_match("/(\w+)\[(d+)\]/i", $el[name], $regs)) {
    if (ereg("([a-zA-Z_]+)\[([0-9]+)\]", $el["name"], $regs)) {
       $el["name"] = sprintf("%s{%s}", $regs[1], $regs[2]);
       $el["multiple"] = true;
    }

We try to match anything that looks like "$foo[9]", so the \[ \]
are correct for literal matches of brackets. Do not change this.
The same is true in oohforms.inc:263.

Kristian

-- 
Kristian Köhntopp, NetUSE Kommunikationstechnologie GmbH
Siemenswall, D-24107 Kiel, Germany, +49 431 386 436 00
Using PHP3? See our web development library at
http://phplib.netuse.de/ (We have moved! Update your bookmarks!)
-
PHPLIB Developers Mailing List. Send messages to <phplib-dev <email protected>>.
To unsubscribe, send "unsubscribe" to <phplib-dev-request <email protected>> in
the body, not the subject, of your message.