Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7156088

JFileChooser accepts illegal filenames

XMLWordPrintable

      J2SE Version (please include all output from java -version flag):
      java version "1.7.0"
      Java(TM) SE Runtime Environment (build 1.7.0-b147)
      Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)

      Operating System Configuration Information (be specific):
      Windows XP [Version 5.1.2600]


      Hardware Configuration Information (be specific):


      Bug Description:
      JFileChooser accepts illegal filenames

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      When you enter a filename or path in the JFileChooser dialog it should not be possible to enter a filename with illegal characters like : * ?

      ACTUAL -
      JFileChooser does not let you select files containing the illegal characters * and ?
      But JFileChooser DOES let you select a file with : (colon)

      This leads to some subsequent errors:
      - when you try to write to a file named "sample:file" java acutally creates the file "sample" but does not write any content and does not throw an Exception either.
      - if you call getCanonicalPath() on the File object ("sample:file") returned by the JFileChooser, java throws an Exception:
      java.io.IOException: Die Syntax f?r den Dateinamen, Verzeichnisnamen oder die Datentr?gerbezeichnung ist falsch
      at java.io.WinNTFileSystem.canonicalize0(Native Method)
      at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:396)
      at java.io.File.getCanonicalPath(File.java:559)

      REPRODUCIBILITY :
      This bug can be reproduced always

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: