Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6D612B6AC5DCDA4580AF97B1068118AD2DD415@DGGEML501-MBX.china.huawei.com>
Date: Sun, 19 Apr 2020 12:26:58 +0000
From: "liheng (P)" <liheng40@...wei.com>
To: Szabolcs Nagy <nsz@...t70.net>
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.

Ok, you are right, I retest to match "aba" by pat[] = "\\(.\\?\\).\\?\\1" success without tags (basic regular expression mode I think).
regcomp1(&rbuf, pat, 0);

But my point is that  why pat[] = "(.?).?\\1"  to match "aba" in extended regular expression mode that success in glibc and failed in musl?   Are musl-regex and glibc-regex different? 


-----Original Message-----
From: Szabolcs Nagy [mailto:nsz@...t70.net] 
Sent: Saturday, April 18, 2020 10:07 PM
To: liheng (P) <liheng40@...wei.com>
Cc: 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: [musl] 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.