Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200418140703.GE23945@port70.net>
Date: Sat, 18 Apr 2020 16:07:03 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: "liheng (P)" <liheng40@...wei.com>
Cc: "musl@...ts.openwall.com" <musl@...ts.openwall.com>,
	Florian Weimer <fw@...eb.enyo.de>, Rich Felker <dalias@...c.org>,
	"Xiangrui (Euler)" <rui.xiang@...wei.com>,
	Lizefan <lizefan@...wei.com>
Subject: Re: regex Back reference matching result not same as glibc
 and tre.

* liheng (P) <liheng40@...wei.com> [2020-04-18 11:37:13 +0000]:
> static const char pat[] = "\\(.?\\).?\\1";
> str = "aba"
> 
> ok, I retest this pat with no tag.

why?

? is not special in bre.
you need "\\{0,1\\}" or "\\?" instead of "?" to match "aba"

your pat would match str="a?b?a?" in a standard conform
implementation.

> 
> regcomp(&rbuf, pat, 0);
> regexec1(&rbuf, str, N, m, 0);
> 
>  glibc:
>  # ./test
>  regexec failed
>  test regex failed
> 
>  musl:
>  # ./test
>  regexec failed
>  test regex failed
> 
> 
> 
> -----Original Message-----
> From: Szabolcs Nagy [mailto:nsz@...t70.net] 
> Sent: Saturday, April 18, 2020 7:13 PM
> To: liheng (P) <liheng40@...wei.com>
> Cc: Florian Weimer <fw@...eb.enyo.de>; Rich Felker <dalias@...c.org>; musl@...ts.openwall.com; Xiangrui (Euler) <rui.xiang@...wei.com>; Lizefan <lizefan@...wei.com>
> Subject: Re: [musl] regex Back reference matching result not same as glibc and tre.
> 
> * liheng (P) <liheng40@...wei.com> [2020-04-18 11:07:20 +0000]:
> > static const char pat[] = "\\(.?\\).?\\1";
> > string: "aba";
> 
> ? is not special in bre
> 
> it should be \{0,1\} (i think we support \? as an extension, but unescaped ? only matches literal ?). try one of
> 
> static const char pat[] = "\\(.\\{0,1\\}\\).\\{0,1\\}\\1"; static const char pat[] = "\\(.\\?\\).\\?\\1";
> 
> > 
> > I tested this pattern by my test case just now.
> > 
> > musl:
> > # ./test
> > regexec failed
> > test regex failed
> > 
> > glibc:
> > # ./test
> > Invalid back reference
> > test regex failed
> > 
> > tre:
> > # ./test
> > Invalid back reference
> > test regex failed
> > 
> > -----Original Message-----
> > From: Florian Weimer [mailto:fw@...eb.enyo.de]
> > Sent: Saturday, April 18, 2020 6:29 PM
> > To: liheng (P) <liheng40@...wei.com>
> > Cc: Rich Felker <dalias@...c.org>; musl@...ts.openwall.com; Xiangrui 
> > (Euler) <rui.xiang@...wei.com>; Lizefan <lizefan@...wei.com>
> > Subject: Re: [musl] regex Back reference matching result not same as glibc and tre.
> > 
> > * liheng:
> > 
> > > static const char pat[] = "(.?).?\\1";
> > 
> > > This commit reminds me that if i want to use back reference i should 
> > > not to tag REG_EXTENDED, but this test case matching still failed.
> > 
> > 
> > Did you change the expression to this for the basic regular expression test?
> > 
> > static const char pat[] = "\\(.?\\).?\\1";

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.