|
Message-Id: <4CAE9FC3-77C9-473B-9A48-345C81A578A7@gmail.com> Date: Sat, 18 Mar 2017 16:00:11 +0100 From: Julien Ramseier <j.ramseier@...il.com> To: musl@...ts.openwall.com Subject: Re: [PATCH] regex: fix newline matching with negated brackets Again with inline patch. I suspect my emails are not received by anyone when adding an attachment... 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 */ > 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.