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

(process) Document the auto-quoting when creating a Windows process; add winQuote

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 6, 6u24
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_xp, windows_7

      Description

      A DESCRIPTION OF THE REQUEST :
      I have a program that uses IrfanView to resize some images (see #4924909 to understand why I'm not resizing them in Java), but I discovered that ProcessImpl automatically add quotes around any element of the command array that has spaces, but doesn't already begin and end with quote marks (it gives an IllegalArgumentException if the element begins with a quote mark but doesn't end with one).


      JUSTIFICATION :
      This is sometimes handy, and should be documented, but some external programs (such as IrfanView) expect a quoted path as part of a parameter, but don't handle it properly if the parameter itself is quoted.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Ability to create a command line such as:
      "c:\program files\irfanview\i_view32.exe" "image 1.jpg" /convert="image 2.jpg" /resize=(100,100)
      ACTUAL -
      Command line becomes:
      "c:\program files\irfanview\i_view32.exe" "image 1.jpg" "/convert="image 2.jpg"" /resize=(100,100)
      and IrfanView gives an error that it failed to load 'image 1.jpg"' (error dialog included double-quote at end, but didn't actually include the single quotes)

      ---------- BEGIN SOURCE ----------
      public class Test {
        public static void main(String[] args) {
          try {
            Runtime.getRuntime().exec(new String[] {"c:\program files\irfanview\i_view32.exe", "image 1.jpg", "/convert=\"image 2.jpg\"", "/resize=(100,100)"});
          } catch (IOException e) {
            e.printStackTrace();
          }
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      (1) For IrfanView, put the resize parameter before the convert parameter.

      (2) Pre-tokenize the parameter that you don't want auto-quoted (e.g. "/convert=\"image", "2.jpg\"") -- this is annoying and would not allow inserting a tab character into such a parameter.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                uta Alexey Utkin (Inactive)
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: