|
|
Message-ID: <20170319033043.GN2082@port70.net>
Date: Sun, 19 Mar 2017 04:30:43 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: Re: [PATCH] regex: fix newline matching with negated
brackets
* Julien Ramseier <j.ramseier@...il.com> [2017-03-18 16:00:11 +0100]:
> diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
> index 5a7b53a..fb24556 100644
> --- a/src/regex/regcomp.c
> +++ b/src/regex/regcomp.c
> @@ -636,6 +636,20 @@ static reg_errcode_t parse_bracket(tre_parse_ctx_t *ctx, const char *s)
> goto parse_bracket_done;
>
> if (neg.negate) {
> + /*
> + * With REG_NEWLINE, POSIX requires that newlines are not matched by
> + * any form of a non-matching list.
> + */
> + if (ctx->cflags & REG_NEWLINE) {
> + lit = tre_new_lit(&ls);
> + if (!lit) {
> + err = REG_ESPACE;
> + goto parse_bracket_done;
> + }
> + lit->code_min = '\n';
> + lit->code_max = '\n';
> + lit->position = -1;
> + }
> /* Sort the array if we need to negate it. */
> qsort(ls.a, ls.len, sizeof *ls.a, tre_compare_lit);
> /* extra lit for the last negated range */
>
looks good.
thanks
>
> > Le 17 mars 2017 à 14:33, Julien Ramseier <j.ramseier@...il.com> a écrit :
> >
> > With REG_NEWLINE, POSIX says:
> > "A <newline> in string shall not be matched by a period outside
> > a bracket expression or by any form of a non-matching list"
> >
> > musl currently matches newlines with negated brackets, even if
> > REG_NEWLINE is used. Attached patch fixes the issue, although
> > I'm not sure if it's the best way to do it.
> >
> > Also see similar glibc bug:
> > https://sourceware.org/bugzilla/show_bug.cgi?id=3957
> >
> > <regcomp-newline-neg-bracket.patch>
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.