changeset 304:64211e906133

PR804: javaws launcher incorrectly handles file names with spaces 2011-10-25 Omair Majid <omajid@redhat.com> PR804: javaws launcher incorrectly handles file names with spaces * NEWS: Update. * launcher/javaws.in: Use bash arrays to store arguments to handle filenames with spaces correctly.
author Omair Majid <omajid@redhat.com>
date Tue, 25 Oct 2011 10:02:45 -0400
parents 9ecf7c8edfe0
children 9f5ea9198a66
files ChangeLog NEWS launcher/javaws.in
diffstat 3 files changed, 50 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 24 16:16:10 2011 +0200
+++ b/ChangeLog	Tue Oct 25 10:02:45 2011 -0400
@@ -1,3 +1,10 @@
+2011-10-25  Omair Majid  <omajid@redhat.com>
+
+	PR804: javaws launcher incorrectly handles file names with spaces
+	* NEWS: Update.
+	* launcher/javaws.in: Use bash arrays to store arguments to handle
+	filenames with spaces correctly.
+
 2011-10-24  Jiri Vanek <jvanek@redhat.com>  
  
 	Added reproducer for - PR788: Elluminate Live! is not working
--- a/NEWS	Mon Oct 24 16:16:10 2011 +0200
+++ b/NEWS	Tue Oct 25 10:02:45 2011 -0400
@@ -16,6 +16,7 @@
   - PR618: Can't install OpenDJ, JavaWebStart fails with Input stream is null error
   - PR765: JNLP file with all resource jars marked as 'lazy' fails to validate signature and stops the launch of application
   - PR788: Elluminate Live! is not working
+  - PR804: javaws launcher incorrectly handles file names with spaces
 * Plugin
   - PR749: sun.applet.PluginStreamHandler#handleMessage(String) really slow
   - PR782: Support building against npapi-sdk as well
--- a/launcher/javaws.in	Mon Oct 24 16:16:10 2011 +0200
+++ b/launcher/javaws.in	Tue Oct 25 10:02:45 2011 -0400
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 JAVA=@JAVA@
 LAUNCHER_BOOTCLASSPATH=@LAUNCHER_BOOTCLASSPATH@
@@ -8,27 +8,57 @@
 PROGRAM_NAME=javaws
 CP=@JRE@/lib/rt.jar
 
-JAVA_ARGS=
-ARGS=
+JAVA_ARGS=( )
+ARGS=( )
+COMMAND=()
+
+i=0
+j=0
 
 while [ "$#" -gt "0" ]; do
   case "$1" in
     -J*)
-      JAVA_ARGS="${JAVA_ARGS} ${1##-J}"
+      JAVA_ARGS[$i]="${1##-J}"
+      i=$((i+1))
       ;;
     *)
-      ARGS="${ARGS} $1"
+      ARGS[$j]="$1"
+      j=$((j+1))
       ;;
   esac
   shift
 done
 
-${JAVA} ${LAUNCHER_BOOTCLASSPATH} ${LAUNCHER_FLAGS} \
-  ${JAVA_ARGS} \
-  -classpath ${CP} \
-  -Dicedtea-web.bin.name=${PROGRAM_NAME} \
-  -Dicedtea-web.bin.location=${BINARY_LOCATION} \
-  ${CLASSNAME} \
-  ${ARGS}
+k=0
+COMMAND[k]="${JAVA}"
+k=$((k+1))
+COMMAND[k]="${LAUNCHER_BOOTCLASSPATH}"
+k=$((k+1))
+COMMAND[k]="${LAUNCHER_FLAGS}"
+k=$((k+1))
+i=0
+while [ "$i" -lt "${#JAVA_ARGS[@]}" ]; do
+  COMMAND[k]="${JAVA_ARGS[$i]}"
+  i=$((i+1))
+  k=$((k+1))
+done
+COMMAND[k]="-classpath"
+k=$((k+1))
+COMMAND[k]="${CP}"
+k=$((k+1))
+COMMAND[k]="-Dicedtea-web.bin.name=${PROGRAM_NAME}"
+k=$((k+1))
+COMMAND[k]="-Dicedtea-web.bin.location=${BINARY_LOCATION}"
+k=$((k+1))
+COMMAND[k]="${CLASSNAME}"
+k=$((k+1))
+j=0
+while [ "$j" -lt "${#ARGS[@]}" ]; do
+  COMMAND[k]="${ARGS[$j]}"
+  j=$((j+1))
+  k=$((k+1))
+done
+
+"${COMMAND[@]}"
 
 exit $?