public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/102447] std::regex incorrectly accepts invalid bracket expression Date: Fri, 24 Sep 2021 21:32:46 +0000 [thread overview] Message-ID: <bug-102447-4-egeZdAshEU@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102447-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102447 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Actually, this might not be a bug. We have this comment in regex_compiler.tcc // POSIX doesn't allow '-' as a start-range char (say [a-z--0]), // except when the '-' is the first or last character in the bracket // expression ([--0]). ECMAScript treats all '-' after a range as a // normal character. Also see above, where _M_expression_term gets called. // // As a result, POSIX rejects [-----], but ECMAScript doesn't. // Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax. // Clang (3.5) always uses ECMAScript style even in its POSIX syntax. // // It turns out that no one reads BNFs ;) So [\w-a] is valid for the ECMAScript syntax and is equivalent to POSIX [-_[:alnum:]]. You can confirm this using your browser's javascript console, where this will print true: RegExp('[\\w-a]').test('-')
next prev parent reply other threads:[~2021-09-24 21:32 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-22 10:06 [Bug libstdc++/102447] New: " redi at gcc dot gnu.org 2021-09-24 18:50 ` [Bug libstdc++/102447] " mpolacek at gcc dot gnu.org 2021-09-24 19:03 ` redi at gcc dot gnu.org 2021-09-24 21:32 ` redi at gcc dot gnu.org [this message] 2021-09-27 11:45 ` redi at gcc dot gnu.org 2021-10-01 10:24 ` redi at gcc dot gnu.org 2021-10-02 1:28 ` rs2740 at gmail dot com 2021-10-02 6:55 ` redi at gcc dot gnu.org 2021-10-02 16:54 ` rs2740 at gmail dot com 2021-10-04 5:09 ` s.ikarashi at fujitsu dot com 2021-12-13 22:27 ` redi at gcc dot gnu.org 2021-12-14 21:47 ` cvs-commit at gcc dot gnu.org 2021-12-14 21:51 ` redi at gcc dot gnu.org 2022-07-07 23:33 ` cvs-commit at gcc dot gnu.org 2022-07-07 23:37 ` redi at gcc dot gnu.org 2023-06-23 16:12 ` cvs-commit at gcc dot gnu.org 2023-06-23 16:18 ` redi at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-102447-4-egeZdAshEU@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).