Mojira Archive
MC-113208

gameDir containing dots breaks some file opening methods

Based on 1.11.2 decompiled using MCP 9.35 rc1

The bug

Some file opening methods do not work when Minecraft is launched with a gameDir containing dots.

Affected situations

List might be incomplete
Last updated for 1.11.2

  • opening screenshots (net.minecraft.util.ScreenShotHelper.saveScreenshot(File, String, int, int, Framebuffer))
  • opening crash reports
    • net.minecraft.client.Minecraft.displayCrashReport(CrashReport)
    • net.minecraft.server.MinecraftServer.run()
  • parts of realms (?) (net.minecraft.realms.Realms.getGameDirectoryPath())

How to reproduce (old Java launcher)

  1. Create a profile with the following game directory
    ./game-data
    
  2. Start Minecraft with the profile
  3. Take a screenshot and try to open it by clicking on the message in chat
    → The file is not opened

Additionally something like the following will appear in the Game Output of your launcher:

20:02:05] [Client thread/ERROR]: Couldn't open link: Failed to open file:/LAUNCHER_PATH/./game-data/screenshots/2017-02-04_19.58.40.png. Error message: The system cannot find the file specified.

Code analysis

This happens because the affected methods call the method java.io.File.getAbsolutePath() for the screenshot file path which does not resolve dots. Instead the method java.io.File.getCanonicalPath() could be used.

Invalid

Marcono1234

2017-02-04, 09:06 PM

2020-02-16, 12:31 AM

2020-02-16, 12:31 AM

3

1

Confirmed

(Unassigned)

file, game-directory, screenshot

Minecraft 1.11.2, Minecraft 1.12

-