Bug 232565 - Regex implementation should not accept + modifier after {N}
Summary: Regex implementation should not accept + modifier after {N}
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Kyle Evans
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-23 16:06 UTC by Alex Richardson
Modified: 2023-04-20 04:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Richardson freebsd_committer freebsd_triage 2018-10-23 16:06:40 UTC
The macOS regex library rejects a regex like
"SHM_[A-Z]+[[:space:]]+[0-9]{6}+" since there is an additional + character after the {N} group.

I believe this should not be accepted since there is already a quantifer after the [0-9].

See also https://svnweb.freebsd.org/changeset/base/339635
Comment 1 Kyle Evans freebsd_committer freebsd_triage 2020-02-21 13:58:00 UTC
Tagging this for PRs that I'll close once bsdgrep becomes the default -- regex(3) actually does reject this, as exemplified by:

$ echo "SHM_FOOO 000000" | bsdgrep -Ee 'SHM_[A-Z]+[[:space:]]+[0-9]{6}+'
grep: repetition-operator operand invalid
Comment 2 commit-hook freebsd_committer freebsd_triage 2020-12-08 14:05:59 UTC
A commit references this bug:

Author: kevans
Date: Tue Dec  8 14:05:27 UTC 2020
New revision: 368439
URL: https://svnweb.freebsd.org/changeset/base/368439

Log:
  src.opts.mk: switch to bsdgrep as /usr/bin/grep

  This has been years in the making, and we all knew it was bound to happen
  some day. Switch to the BSDL grep implementation now that it's been a
  little more thoroughly tested and theoretically supports all of the
  extensions that gnugrep in base had with our libregex(3).

  Folks shouldn't really notice much from this update; bsdgrep is slower than
  gnugrep, but this is currently the price to pay for fewer bugs. Those
  dissatisfied with the speed of grep and in need of a faster implementation
  should check out what textproc/ripgrep and textproc/the_silver_searcher
  can do for them.

  I have some WIP to make bsdgrep faster, but do not consider it a blocker
  when compared to the pros of switching now (aforementioned bugs, licensing).

  PR:		228798 (exp-run)
  PR:		128645, 156704, 166842, 166862, 180937, 193835, 201650
  PR:		232565, 242308, 246000, 251081, 191086, 194397
  Relnotes:	yes, please

Changes:
  head/share/mk/src.opts.mk
Comment 3 Kyle Evans freebsd_committer freebsd_triage 2023-04-20 04:44:39 UTC
Missed this one; not an issue since the replacement of grep.