[Mono-bugs] [Bug 477408] New: MaskedTextBox: Doesn't handle invalid input correctly

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Feb 18 15:20:37 EST 2009


           Summary: MaskedTextBox: Doesn't handle invalid input correctly
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i686
        OS/Version: openSUSE 11.0
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: btaylor1 at novell.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

On Windows, MaskedTextBox fails silently if you set Text to, for example, an
"a" character when Mask only accepts numeric values.  mono-2-4 branch, r127291
and Mono 1.9.1 both crash with an ArgumentOutOfRangeException.

Steps to reproduce:
1. Compile and run the attached sample.
2. Press "Click Me"


System.ArgumentOutOfRangeException: Cannot be negative.
Parameter name: length
  at System.String.Substring (Int32 startIndex, Int32 length) [0x00000] 
  at System.Windows.Forms.MaskedTextBox.InputText (System.String text, Boolean
overwrite, Boolean clear) [0x00000] 
  at System.Windows.Forms.MaskedTextBox.set_Text (System.String value)
  at MaskedTextBoxTest+TestForm+<TestForm>c__AnonStorey0.<>m__0 (System.Object
, System.EventArgs ) [0x00000] 
  at (wrapper delegate-invoke)
  at System.Windows.Forms.Control.OnClick (System.EventArgs e) [0x00000] 
  at System.Windows.Forms.Button.OnClick (System.EventArgs e) [0x00000] 
  at System.Windows.Forms.ButtonBase.OnMouseUp
(System.Windows.Forms.MouseEventArgs mevent) [0x00000] 
  at System.Windows.Forms.Button.OnMouseUp (System.Windows.Forms.MouseEventArgs
mevent) [0x00000] 
  at System.Windows.Forms.Control.WmLButtonUp (System.Windows.Forms.Message& m)
  at System.Windows.Forms.Control.WndProc (System.Windows.Forms.Message& m)
  at System.Windows.Forms.ButtonBase.WndProc (System.Windows.Forms.Message& m)
  at System.Windows.Forms.Button.WndProc (System.Windows.Forms.Message& m)
  at System.Windows.Forms.Control+ControlWindowTarget.OnMessage
(System.Windows.Forms.Message& m) [0x00000] 
  at System.Windows.Forms.Control+ControlNativeWindow.WndProc
(System.Windows.Forms.Message& m) [0x00000] 
  at System.Windows.Forms.NativeWindow.WndProc (IntPtr hWnd, Msg msg, IntPtr
wParam, IntPtr lParam) [0x00000] 

Expected Results:
Nothing happens, and the MaskInputRejected handler should be fired.

Configure bugmail: https://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