Bug 188330 - Problems Copying files with $ in name
Summary: Problems Copying files with $ in name
Status: CLOSED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M5   Edit
Assignee: Martin Oberhuber CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords: bugday
: 168220 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-05-22 10:58 EDT by Kevin Doyle CLA
Modified: 2008-09-16 16:35 EDT (History)
3 users (show)

See Also:


Attachments
there is no need to escape special chars on Windows if the arguments are enclosed with double quotes (2.31 KB, patch)
2008-02-10 15:21 EST, Radoslav Gerganov CLA
no flags Details | Diff
A better patch (in line with dstore CopyThread) (5.30 KB, patch)
2008-02-11 06:34 EST, Martin Oberhuber CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Doyle CLA 2007-05-22 10:58:05 EDT
When copying a file that starts with $, the file is created in the new folder, but it's contents are not copied.

When copying a file that has $ in the name, but not at the beginning I get a NPE.

!ENTRY org.eclipse.core.jobs 4 2 2007-05-22 10:42:22.800
!MESSAGE An internal error occurred during: "Transfer Operation".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.rse.ui.messages.SystemMessageDialog.<init>(SystemMessageDialog.java:168)
	at org.eclipse.rse.ui.messages.SystemMessageDialog.displayErrorMessage(SystemMessageDialog.java:625)
	at org.eclipse.rse.ui.messages.SystemMessageDialog.displayMessage(SystemMessageDialog.java:674)
	at org.eclipse.rse.internal.files.ui.view.SystemViewRemoteFileAdapter.doDrop(SystemViewRemoteFileAdapter.java:1998)
	at org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable.transferRSEResources(SystemDNDTransferRunnable.java:251)
	at org.eclipse.rse.internal.ui.view.SystemDNDTransferRunnable.runInWorkspace(SystemDNDTransferRunnable.java:572)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Steps to Reproduce:
Create 2 new files and name them a$.txt and $a.txt.  
Add some text to the files and save them.
Create a new folder.
Copy and paste one file at a time to the new folder.

-----------Enter bugs above this line-----------
TM 2.0M7 Testing
installation : eclipse-SDK-3.3M7
RSE install  : 2.0M7
java.runtime : Sun 1.5.0_11-b03
os.name:     : Windows XP, Service Pack 2
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-05-22 12:10:56 EDT
I'll look at this.
Comment 2 Radoslav Gerganov CLA 2008-02-10 15:14:55 EST
$ is considered a special char by the LocalFileService which is not correct on a Windows platform. Moreover, reserved shell charactes should be escaped with ^ instead of \ on Windows. This is what MSDN says:

"all reserved shell characters not in double quotes must be escaped. These characters have special meaning to the Windows NT command shell. The reserved shell characters are:
& | ( ) < > ^
To pass reserved shell characters as part of an argument for a command, either the entire argument must be enclosed in double quotes, or the reserved character must be escaped."

Both source and target arguments are enclosed with double quotes in LocalFileService#copy(), so there is no need to escape them if we are running on 
Windows. I will propose a patch.
Comment 3 Radoslav Gerganov CLA 2008-02-10 15:21:57 EST
Created attachment 89357 [details]
there is no need to escape special chars on Windows if the arguments are enclosed with double quotes
Comment 4 Martin Oberhuber CLA 2008-02-11 06:34:28 EST
Created attachment 89388 [details]
A better patch (in line with dstore CopyThread)

Thanks for finding the problem, it helped me come up with a different patch.

Since we're using the same functionality for the dstore-Windows server I checked what we're doing there (find it in 
   org.eclipse.rse.services.dstore
      /miners/
         org.eclipse.rse.internal.dstore.universal.miners.filesystem/
            CopyThread.java

there, we are using an enQuote() method taking care of the windows/unix differences, and using PathUtility.enQuoteUnix() for the UNIX enquoting. 
Using that code, I was able to accomplish the same but getting rid of a quite a bit of unnecessary code.
Comment 5 Martin Oberhuber CLA 2008-02-11 06:37:03 EST
Patch tested and committed.
Comment 6 Kevin Doyle CLA 2008-02-14 15:29:03 EST
Verified fixed in I20080213-1800.
Comment 7 Martin Oberhuber CLA 2008-09-16 16:35:51 EDT
*** Bug 168220 has been marked as a duplicate of this bug. ***