[Mono-bugs] [Bug 577346] Regex constructor throws ArgumentException: range in reverse order

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Jul 19 19:49:15 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=577346

http://bugzilla.novell.com/show_bug.cgi?id=577346#c2


--- Comment #2 from Miguel de Icaza <miguel at novell.com> 2010-07-19 23:49:13 UTC ---
It seems like the only way to solve this will be to scan the regular expression
twice and cant be done with a single pass.


I tried this change in parse.cs's ParseEscape:


                //
                // It could be an octal value that starts with
                // a digit, as long as the \N is less than the number
                // of capture groups
                //
            case '1': case '2': case '3': case '4': case '5':
            case '6': case '7': {
                    ptr--;
                    int oprevptr = ptr;
                    int dresult = ParseDecimal (pattern, ref ptr);

                    // If it is a backreference, let the ParseSpecial handle
it.
                    if (dresult < 10 || dresult <= caps.Count){
                        ptr = p;
                        return -1;
                    }
                    ptr = oprevptr;
                    return ParseOctal (pattern, ref ptr);
                }

But this change breaks with a regular expression like this (it currently
passes):

Matching input 'aa' against pattern '\10((((((((((a))))))))))' with options
'RightToLeft'

The above change is also wrong in that it ignores the Options = EcmaScript that
would use the old interpretation.

Alternatively, we could fix this by changing the backreferences into characters
in the resolve phase after the parsing is complete.

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list