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

Desktop API does not work as expected for file scheme URI

    Details

    • Subcomponent:
    • Understanding:
      Cause Known
    • CPU:
      x86
    • OS:
      linux

      Description

      OPERATING SYSTEM(S):
      --------------------
      Red Hat Enterprise Linux 5 (Japanese Environment)

      FULL JDK VERSION(S):
      -------------------
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode)

      DESCRIPTION:
      ------------
      Desktop API does not work as expected for file scheme URI if URI has non-ASCII character.
      It seems non-ASCII character is not escaped properly.
      Since gnome-open command works fine, Desktop API should work.

      Steps to Recreate:

      (Please run following commands on Japanese environment)

      1. Compile and run attached testcase

         $ cd /tmp
         $ javac DesktopOpenTest.java
         $ export LC_MESSAGES=C
         $ echo "test" > `echo -e "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a.txt"`
         $ gedit "file:$PWD/%e3%81%82%e3%81%84%e3%81%86%e3%81%88%e3%81%8a.txt" &
         $ java DesktopOpenTest "file:$PWD/%e3%81%82%e3%81%84%e3%81%86%e3%81%88%e3%81%8a.txt"

      2. Following message is displayed on console
         file:/tmp/XXXXX.txt: malformed fuke bane or URI <== PROBLEM
         (Note: XXXXX is Japanese Characters (AIUEO))


      =====================================================================
      import java.awt.*;
      import java.io.*;
      import java.net.*;

      class DesktopOpenTest {
        DesktopOpenTest(String uri) {
          Desktop desktop = Desktop.getDesktop();
          if (desktop.isSupported(Desktop.Action.OPEN)) {
            System.out.println("Open "+uri+" ...");
            try {
              desktop.open(new File(new URI(uri)));
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        }
        public static void main(String[] args) {
          for(String uri: args) new DesktopOpenTest(uri);
        }
      }

        Attachments

          Activity

            People

            • Assignee:
              denis Denis Fokin (Inactive)
              Reporter:
              elarsen Erik Larsen (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Imported:
                Indexed: