Thread overview
[Issue 11775] New: std.regex should check for valid repetition range in assert mode
Dec 19, 2013
Andrej Mitrovic
Dec 19, 2013
Dmitry Olshansky
Dec 20, 2013
Andrej Mitrovic
December 19, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11775

           Summary: std.regex should check for valid repetition range in
                    assert mode
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-12-19 08:27:52 PST ---
-----
import std.regex;

void main()
{
    auto m = "12".match(r"\d{1,0}");  // invalid range
}
-----

$ dmd -run test.d
> core.exception.RangeError@std.regex(5019): Range violation

Note that the exception is internal while trying to access an invalid index in an array. With -noboundscheck there will be no exceptions thrown.

I think at least in assert mode ( version(assert) ) the repetition range should
be verified to be valid.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 19, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11775


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |dmitry.olsh@gmail.com


--- Comment #1 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2013-12-19 10:13:09 PST ---
https://github.com/D-Programming-Language/phobos/pull/1791

I think it should throw just like any other parse error, after all patterns are user input in certain systems (like editors).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 19, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11775



--- Comment #2 from github-bugzilla@puremagic.com 2013-12-19 12:24:16 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/e598f92224db6e28603e1421d3b3e5e47422bbe5 fix issue 11775 std.regex should check for valid repetition range

https://github.com/D-Programming-Language/phobos/commit/ff23ea79975e9ffb7edf16370563b3253a882f99 Merge pull request #1791 from blackwhale/range-bug-regex

fix issue 11775 std.regex should check for valid repetition range

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 20, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11775


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-12-20 00:48:53 PST ---
Thanks!

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------