[Mono-bugs] [Bug 53014][Wis] New - Regex parsing problem

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sun, 18 Jan 2004 02:49:17 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kelvin.ho@kawai.ca.

http://bugzilla.ximian.com/show_bug.cgi?id=53014

--- shadow/53014	2004-01-18 02:49:17.000000000 -0500
+++ shadow/53014.tmp.25844	2004-01-18 02:49:17.000000000 -0500
@@ -0,0 +1,120 @@
+Bug#: 53014
+Product: Mono/Runtime
+Version: unspecified
+OS: 
+OS Details: XP SP1
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: kelvin.ho@kawai.ca               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Regex parsing problem
+
+Description of Problem:
+Regex parsing problem
+
+Steps to reproduce the problem:
+1. mcs k4.cs
+2. mono k4
+
+k4.cs:
+using System;
+using System.Text.RegularExpressions;
+
+public class K4
+{
+  private const string regex =
+               "[\\s;]*"
+              +"(?<key>([^=\\s]|\\s+[^=\\s]|\\s+==|==)+)"
+              +   "\\s*=(?!=)\\s*"
+              +"(?<value>("
+              +   "(" + "\"" + "([^\"]|\"\")*" + "\"" + ")"
+              +   "|"
+              +   "(" + "'" + "([^']|'')*" + "'" + ")"
+              +   "|"
+              +   "(" + "{" + "([^{]|{})*" + "}" + ")"
+              +   "|"
+              +   "(" + "(?![\"'])" + "([^\\s;]|\\s+[^\\s;])*" +
+                  "(?<![\"'])" + ")"
+              + "))"
+              + "[\\s;]*";
+
+  public K4()
+  {
+  }
+
+  public Int32 Test( Int32 z )
+  {
+    Regex x = new Regex( regex, RegexOptions.ExplicitCapture );
+    return z;
+  }
+
+  public static void Main()
+  {
+    K4 K4 = new K4();
+    K4.Test( 10 );
+  }
+}
+
+Actual Results:
+Unhandled Exception: System.ArgumentException: parsing "[\s;]*(?<key>
+([^=\s]|\s+
+[^=\s]|\s+==|==)+)\s*=(?!=)\s*(?<value>(("([^"]|"")*")|('([^']|'')*')|
+({([^{]|{}
+)*})|((?!["'])([^\s;]|\s+[^\s;])*(?<!["']))))[\s;]*" - Bad quantifier.
+Parameter name: [\s;]*(?<key>([^=\s]|\s+[^=\s]|\s+==|==)+)\s*=(?!=)\s*(?
+<value>(
+("([^"]|"")*")|('([^']|'')*')|({([^{]|{})*})|((?!["'])([^\s;]|\s+[^\s;])*
+(?<!["'
+]))))[\s;]*
+in <0x00618> System.Text.RegularExpressions.Syntax.Parser:ParseGroup 
+(System.Tex
+t.RegularExpressions.Syntax.Group,System.Text.RegularExpressions.RegexOpti
+ons,Sy
+stem.Text.RegularExpressions.Syntax.Assertion)
+in <0x001b2> 
+System.Text.RegularExpressions.Syntax.Parser:ParseGroupingConstruct
+ (System.Text.RegularExpressions.RegexOptions&)
+in <0x0040b> System.Text.RegularExpressions.Syntax.Parser:ParseGroup 
+(System.Tex
+t.RegularExpressions.Syntax.Group,System.Text.RegularExpressions.RegexOpti
+ons,Sy
+stem.Text.RegularExpressions.Syntax.Assertion)
+in <0x001b2> 
+System.Text.RegularExpressions.Syntax.Parser:ParseGroupingConstruct
+ (System.Text.RegularExpressions.RegexOptions&)
+in <0x0040b> System.Text.RegularExpressions.Syntax.Parser:ParseGroup 
+(System.Tex
+t.RegularExpressions.Syntax.Group,System.Text.RegularExpressions.RegexOpti
+ons,Sy
+stem.Text.RegularExpressions.Syntax.Assertion)
+in <0x005e1> 
+System.Text.RegularExpressions.Syntax.Parser:ParseGroupingConstruct
+ (System.Text.RegularExpressions.RegexOptions&)
+in <0x0040b> System.Text.RegularExpressions.Syntax.Parser:ParseGroup 
+(System.Tex
+t.RegularExpressions.Syntax.Group,System.Text.RegularExpressions.RegexOpti
+ons,Sy
+stem.Text.RegularExpressions.Syntax.Assertion)
+in <0x00087> 
+System.Text.RegularExpressions.Syntax.Parser:ParseRegularExpression
+ (string,System.Text.RegularExpressions.RegexOptions)
+in <0x0009e> System.Text.RegularExpressions.Regex:.ctor 
+(string,System.Text.Regu
+larExpressions.RegexOptions)
+in <0x00039> .K4:Test (int)
+in <0x0003c> .K4:Main ()
+
+Expected Results:
+This problem is ok with .NET.
+
+How often does this happen? 
+Every time.
+
+Additional Information: