Mojira Archive
MC-131152

Structure name allows detecting if server is running under Windows

The bug

Structure blocks allow detecting if the server is running under Windows by using structure names which are not allowed folder names under Windows, see this StackOverflow answer.

How to reproduce

  1. /setblock ~ ~ ~ structure_block[mode=save]{mode:"SAVE",name:"con/test"}
    
  2. Open the structure block GUI and click "SAVE"
    Under Windows it should say "Unable to save structure"; for every other OS it should work fine

Possible solutions

Here are some possible solutions I came up with. It appears prefixing or suffixing all path pieces could solve this problem, for example:
aux:con/test_aux/_con/_test
But this means either minecraft has to be prefixed as well or needs to have a special case.
It would probably be a good idea to provide this as a method of the resource location class returning it as a sanitized path.

Solution Description Advantages Disadvantages
Use hashed structure names Hash structure names for example using MD5 -
  • Hash collisions
  • Makes it difficult to get the structure name from the file name
Base64 structure name Base64 structure names -
  • Could result in a Base64 encoded value which causes this bug (but appears to not be the case)
  • Makes it difficult to get the structure name from the file name
Use index file Give arbitrary file names and have an index file which maps structure name to file name -
  • Sharing index file may disclose other structure names
  • Sharing structures is more difficult
Saving structure name in NBT data Save the structure name only in the NBT data and use arbitrary file names -
  • Makes it difficult to detect duplicate structure names
Use complete structure name as file name Don't create folders but instead use the complete structure name as file name, replacing all characters which might be problematic on some OS using a character which is invalid in structure names.
  • Makes it easy to get the structure name from the file name
  • All structures are in the same folder; can get messy with many structures
Prefix / suffix all path pieces Prefix or suffix all path pieces to prevent them from having a not allowed name.
  • Makes it easy to get the structure name from the file name
  • Still supports folder structure
-

You could still have a folder structure for most solutions by using common prefixes (if files names will always have a minimum length), however the common prefixes should not cause the described bug as well.

Fixed

Marcono1234

[Mojang] Bartosz Bok

2018-06-10, 12:16 AM

2018-06-16, 12:39 AM

2018-06-13, 11:59 AM

1

2

Confirmed

resource-location, structure_block

Minecraft 1.12.2, Minecraft 1.13-pre1

Minecraft 1.13-pre2