minecraft-dev / MinecraftDev

Plugin for IntelliJ IDEA that gives special support for Minecraft modding projects.
https://minecraftdev.org/
GNU Lesser General Public License v3.0
1.46k stars 180 forks source link

Apache 2.0 LICENSE file detected as NBT #2266

Open jpenilla opened 4 months ago

jpenilla commented 4 months ago

Minecraft Development for IntelliJ plugin version

2023.3-1.7.3

IntelliJ version

IntelliJ IDEA 2023.3.6 (Ultimate Edition) Build #IU-233.15026.9, built on March 20, 2024

Operating System

macOS 14.4

Target platform

No response

Description of the bug

Apache 2.0 LICENSE files often get detected as NBT files and need to have the file type manually overridden to plain text. Screenshot 2024-03-21 at 9 58 46 PM Screenshot 2024-03-21 at 9 58 55 PM

Earthcomputer commented 4 months ago

The license file has no file extension so mcdev then checks to see if the first 10kb of the file can be interpreted as NBT. The first byte of the Apache 2.0 license is 10 (newline) if you are using unix line endings, which coincidentally is the same as the compound tag ID, which is what is required at the top level of the NBT. I can imagine that from here it's quite easy to produce text files that look like valid NBT for the first 10kb, because the next step is to read the next two bytes as a big-endian length for a string to read.

sylv256 commented 4 months ago

Now all we have to do is make an NBT polyglot license...