JDK-8040007 : GtkFileDialog strips user inputted filepath
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86
  • Submitted: 2014-04-11
  • Updated: 2015-01-21
  • Resolved: 2014-06-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
8u40Fixed 9 b22Fixed
Related Reports
Duplicate :  
Relates :  
*** Please read the latest comment on why this looks like an awt issue ***

This is a multi-stage test.  Click on "done" when you have completed
reading these instructions.
First, policytool will be invoked.
Then, follow these steps:
0) Find (or create) a temporary directory that you have write access to.(Example: 'C:\foo\tmp' on Windows or '/tmp' on other systems)
1) Click on the "Add Policy Entry" button in the main policytool window.
2) Click on the "Add Permission" button in the Policy Entry window.
3) In the Permission window, pull down the "Permission" menu and select "AWTPermission".
4) In the Permission window, pull down the "Target Name" menu and select "listenToAllAWTEvents".
5) Click on the "OK" button in the Permission window.
6) Click on the "Done" button in the Policy Entry window.
7) In the main policytool window, pull down the "File" menu and select "Save As".
8) In the SaveAs window, enter "/tmp/ptool.test" as the file name and save it. If the file already exists, just replace it. (Or use the temporary directory mentioned in Step 0 if it's not '/tmp'.For  example, "C:\foo\tmp\ptool.test" on Windows)
9) Check the content of the file created in the previous step
10) check to make sure that the new entry is in the policy file.
11) repeat steps 1-10 for:
	AWTPermission:		readDisplayPixels
	NetPermission:		specifyStreamHandler
	RuntimePermission:	                  setContextClassLoader,
	SecurityPermission:	                  createAccessControlContext

In the confirmation dialog pop-up, click "OK".
Exit policytool. Delete the files created during this test. If the
temporary directory is also newly created, empty and delete it.
Press "Pass" if ... press "Fail" otherwise.

Actual behavior:
The step 8, In the SaveAs window, enter "/tmp/ptool.test" to file name field and click save button, the 'ptool.test' be saved in the default directory( '/regression/results/workDir/scrath') instead of  '/tmp' refer to UpdatePermissions1.jpg and UpdatePermissions2.jpg.  Actually, it can be saved in '/tmp' directory when we select to '/tmp' directory before click save button refer to UpdatePermissions3.jpg and UpdatePermissions4.jpg.

9b05 (32bit) on win7-sp1- x86:it is pass.
9b06 (64bit) on win8- x64:it is pass.

Running this program import java.awt.*; public class T1 { public static void main(String[] args) throws Exception { FileDialog fd = new FileDialog((Frame)null, "Save.As", FileDialog.SAVE); fd.setVisible(true); System.out.println(fd.getDirectory()); System.out.println(fd.getFile()); } } After the dialog is shown, click on any folder on the left pane, and enter "/tmp/p" as the file name. Click OK, and the "/tmp/" part is stripped from the file name. It looks like the hack on line 269 of jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c should be used here, which means full_path_names should be true if the user does input a full path name. Reassign to AWT.

Yes, I can reproduce the problem. PolicyTool.java uses File saveAsFile = new File(fd.getDirectory(), fd.getFile()); to determine where to save the file. Here, fd.getDirectory() returns the scratch dir and fd.getFile() returns "ptool.test" only. Hence the error, and I don't know how to explain.

Thank you Tony and Michael for updating the information.

we confirm that we used the latest version and update case instruction.

http://hg.openjdk.java.net/jdk9/dev/jdk/file/jdk9-b07/test/sun/security/tools/policytool/UpdatePermissions.html is already updated with JDK-8015276. In fact, the steps shown above are different from the ones in the file. Especially, the current step 8 has: 8) In the SaveAs window, enter "/tmp/ptool.test" as the file name and save it. If the file already exists, just replace it.<br> (Or use the temporary directory mentioned in Step 0 if it's not '/tmp'. For example, "C:\foo\tmp\ptool.test" on Windows)<br><br> Please confirm if reporter is using the latest version.

This changeset appears to be in JDK 9, when it was created from JDK 8. Is there a different problem here? % cat .hg/hgrc [paths] default = http://hg.openjdk.java.net/jdk9/dev/jdk % hg log -v | grep 8015276 8015276: TEST_BUG: The 'ptool.test' can't be saved in the 'tmp' folder.

Need forward port of JDK-8015276 to JDK 9

Issue is reproduced against JDK 9 b07 on Oracle linux 6.4 x64

add case name for aurora: sun/security/tools/policytool/UpdatePermissions.sh