JDK-4747316 : Entering bad pattern in JFileChooser causes PatternSyntaxException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_nt,windows_2000
  • CPU: x86
  • Submitted: 2002-09-13
  • Updated: 2003-03-13
  • Resolved: 2003-01-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.4.1_03 03Fixed 1.4.2Fixed
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 09/13/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0

A DESCRIPTION OF THE PROBLEM :
Entering a bad pattern as the filename in a JFileChooser
causes uncaught java.util.regex.PatternSyntaxException.
For example,  \C.*  will cause this.

Also, there is a typo in the error message. Sequence
is spelled "squence".


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Run attached code.
2. Enter  \C.*  as the filename and hit enter.
3.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expect an error dialog for the user indicating a bad
pattern or something similar. Instead, there is an
uncaught exception.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.regex.PatternSyntaxException: Illegal/unsupported escape squence near
index 1
\C..*
 ^
	at java.util.regex.Pattern.error(Pattern.java:1472)
	at java.util.regex.Pattern.escape(Pattern.java:1900)
	at java.util.regex.Pattern.atom(Pattern.java:1661)
	at java.util.regex.Pattern.sequence(Pattern.java:1545)
	at java.util.regex.Pattern.expr(Pattern.java:1489)
	at java.util.regex.Pattern.compile(Pattern.java:1257)
	at java.util.regex.Pattern.<init>(Pattern.java:1013)
	at java.util.regex.Pattern.compile(Pattern.java:783)
	at javax.swing.plaf.basic.BasicFileChooserUI$GlobFilter.setPattern
(BasicFileChooserUI.java:913)
	at
javax.swing.plaf.basic.BasicFileChooserUI$ApproveSelectionAction.actionPerformed
(BasicFileChooserUI.java:756)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1502)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2422)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2468)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2385)
	at java.awt.Component.processEvent(Component.java:4830)
	at java.awt.Container.processEvent(Container.java:1380)
	at java.awt.Component.dispatchEventImpl(Component.java:3526)
	at java.awt.Container.dispatchEventImpl(Container.java:1437)
	at java.awt.Component.dispatchEvent(Component.java:3367)
	at java.awt.KeyboardFocusManager.redispatchEvent
(KeyboardFocusManager.java:1700)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent
(DefaultKeyboardFocusManager.java:568)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent
(DefaultKeyboardFocusManager.java:739)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions
(DefaultKeyboardFocusManager.java:673)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent
(DefaultKeyboardFocusManager.java:534)
	at java.awt.Component.dispatchEventImpl(Component.java:3396)
	at java.awt.Container.dispatchEventImpl(Container.java:1437)
	at java.awt.Window.dispatchEventImpl(Window.java:1566)
	at java.awt.Component.dispatchEvent(Component.java:3367)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:445)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:190)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:144)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;

    public class JFileChooserBug2 {
       public static void main(String args[]) {
         JFileChooser fc = new JFileChooser();
         fc.showOpenDialog(null);
      }
   }


---------- END SOURCE ----------
(Review ID: 164457) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.4.1_03 mantis-beta FIXED IN: 1.4.1_03 mantis-beta INTEGRATED IN: 1.4.1_03 mantis-b12 mantis-beta
14-06-2004

EVALUATION The handling of the \ character was incomplete for the windows platform. Other symptoms are that the pattern *.cd would match files like a.bcd and abcd. ###@###.### 2002-10-11
11-10-2002