United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4747316 : Entering bad pattern in JFileChooser causes PatternSyntaxException

Details
Type:
Bug
Submit Date:
2002-09-13
Status:
Resolved
Updated Date:
2003-03-13
Project Name:
JDK
Resolved Date:
2003-01-04
Component:
client-libs
OS:
windows_nt,windows_2000
Sub-Component:
javax.swing
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.1
Fixed Versions:
1.4.1_03 (03)

Related Reports
Backport:
Duplicate:

Sub Tasks

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
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
                                     
2002-10-11
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


                                     
2004-06-14



Hardware and Software, Engineered to Work Together