diff options
author | Szabolcs Nagy <nsz@port70.net> | 2015-04-18 17:28:49 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2016-01-30 20:53:42 -0500 |
commit | 25160f1c08235cf5b6a9617c5640380618a0f6ff (patch) | |
tree | a71afcd0c327dc78a2e005c3b8d749ab9554305a /src/regex | |
parent | 03498ec22a4804ddbd8203d9ac94b6f7b6574b3c (diff) | |
download | musl-25160f1c08235cf5b6a9617c5640380618a0f6ff.zip musl-25160f1c08235cf5b6a9617c5640380618a0f6ff.tar.gz musl-25160f1c08235cf5b6a9617c5640380618a0f6ff.tar.bz2 |
regex: treat \+, \? as repetitions in BRE
These are undefined escape sequences by the standard, but often
used in sed scripts.
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/regcomp.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c index ccd3755..b3dbb25 100644 --- a/src/regex/regcomp.c +++ b/src/regex/regcomp.c @@ -838,6 +838,9 @@ static reg_errcode_t parse_atom(tre_parse_ctx_t *ctx, const char *s) s--; break; case '{': + case '+': + case '?': + /* extension: treat \+, \? as repetitions in BRE */ /* reject repetitions after empty expression in BRE */ if (!ere) return REG_BADRPT; @@ -993,7 +996,8 @@ static reg_errcode_t tre_parse(tre_parse_ctx_t *ctx) } if (*s=='\\' && ere) break; - if (*s=='\\' && s[1]!='{') + /* extension: treat \+, \? as repetitions in BRE */ + if (*s=='\\' && s[1]!='+' && s[1]!='?' && s[1]!='{') break; if (*s=='\\') s++; |