This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 122221 - Opening PDF file brings up command console
Summary: Opening PDF file brings up command console
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: PDF (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P1 blocker (vote)
Assignee: Marian Petras
URL:
Keywords: SPACE_IN_PATH
: 120257 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-11-18 04:16 UTC by rptmaestro
Modified: 2007-11-26 13:30 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
binary patch for NB 6.0 (RC 1 or newer) (4.19 KB, application/octet-stream)
2007-11-20 16:55 UTC, Marian Petras
Details
source code patch for branch 'release60' (1.66 KB, patch)
2007-11-23 14:11 UTC, Marian Petras
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rptmaestro 2007-11-18 04:16:59 UTC
Using NetBeans 6.0 RC1. When opening a PDF document from the explorer or attempting to open the Keyboard Shortcuts Card
from the Help menu, the user gets a windows command console instead of the pdf viewer.
Comment 1 Jana Maleckova 2007-11-19 12:42:48 UTC
reassign to utilities
Comment 2 Marian Petras 2007-11-20 14:13:25 UTC
Confirmed on Windows 2000 and Windows XP 64-bit. The new mechanism introduced by fix of bug #119333 ("Common PDF viewer
for Windows") does not work if if path of the PDF file being opened contains space.
Comment 3 Marian Petras 2007-11-20 16:52:51 UTC
The mechanism of the failure is the following:

Running command-line

   cmd.exe /C start ... 

actually executes a built-in command "start" with the given arguments. The root cause of the failure is that I did not
know the strange semantics of the arguments passed to it.

The semantics of the "start" command is that if the first argument is enclosed in quotes, it is considered to be a
windows title (and otherwise ignored). If the Utilities module executes

    Runtime.getRuntime("cmd.exe", "/C", "start", filePath)

and the filePath contains a space character, the JRE automatically encloses the file path in quotes which causes that it
is handled like a windows title.

To prevent it, this patch adds an extra (dummy) argument to the "start" command:

    Runtime.getRuntime("cmd.exe", "/C", "start", "\"PDF Viewer\"", filePath)

which is always handled as a windows title (because it is enclosed in quotes), so that the file path argument is handled
correctly.

Modified file:
    utilities/src/org/netbeans/modules/pdf/PDFOpenSupport.java   (1.19)

Diff:
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/src/org/netbeans/modules/pdf/PDFOpenSupport.java?r1=1.18&r2=1.19
Comment 4 Marian Petras 2007-11-20 16:55:33 UTC
Created attachment 53257 [details]
binary patch for NB 6.0 (RC 1 or newer)
Comment 5 Marian Petras 2007-11-23 08:45:01 UTC
*** Issue 120257 has been marked as a duplicate of this issue. ***
Comment 6 Marian Petras 2007-11-23 14:11:15 UTC
Created attachment 53405 [details]
source code patch for branch 'release60'
Comment 7 Peter Pis 2007-11-23 14:40:48 UTC
Verified the binary patch with latest RC2 build.
Comment 8 Maros Sandor 2007-11-23 15:16:48 UTC
The fix seems OK to me.
Comment 9 Marian Petras 2007-11-26 13:30:19 UTC
Committed to branch 'release60'.

Modified file:
    utilities/src/org/netbeans/modules/pdf/PDFOpenSupport.java   (1.18.2.1)

Diff:
http://deadlock.netbeans.org/fisheye/browse/netbeans/utilities/src/org/netbeans/modules/pdf/PDFOpenSupport.java?r1=1.18&r2=1.18.2.1