WorldEdit for Bukkit

WorldEdit for Bukkit

21M Downloads

Invalid filesystem paths produce stacktrace rather than clean error

josephjthomas opened this issue · 7 comments

commented

WorldEdit Version

7.2.11-SNAPSHOT+6226-ba8e403

Platform Version

git-Paper-81 (MC: 1.19)

Confirmations

  • I am using the most recent Minecraft release.
  • I am using a version of WorldEdit compatible with my Minecraft version.
  • I am using the latest or recommended version of my platform software.
  • I am NOT using a hybrid server, e.g. a server that combines Bukkit and Forge. Examples include Arclight, Mohist, and Cardboard.
  • I am NOT using a fork of WorldEdit, such as FastAsyncWorldEdit (FAWE) or AsyncWorldEdit (AWE)

Bug Description

Schematics with question marks in the name throw a stacktrace:

[00:21:53] [Server thread/ERROR]: An unexpected error while handling a WorldEdit command
java.nio.file.InvalidPathException: Illegal char <?> at index 69: <redacted>
	at sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182) ~[?:?]
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153) ~[?:?]
	at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) ~[?:?]
	at sun.nio.fs.WindowsPath.parse(WindowsPath.java:92) ~[?:?]
	at sun.nio.fs.WindowsUriSupport.fromUri(WindowsUriSupport.java:166) ~[?:?]
	at sun.nio.fs.WindowsFileSystemProvider.getPath(WindowsFileSystemProvider.java:98) ~[?:?]
	at java.nio.file.Path.of(Path.java:203) ~[?:?]
	at java.nio.file.Paths.get(Paths.java:98) ~[?:?]
	at com.sk89q.worldedit.WorldEdit.getSafeFile(WorldEdit.java:335) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.WorldEdit.getSafeSaveFile(WorldEdit.java:279) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.command.SchematicCommands.save(SchematicCommands.java:174) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.command.SchematicCommandsRegistration.cmd$save(SchematicCommandsRegistration.java:173) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at org.enginehub.piston.CommandManager.execute(CommandManager.java:157) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.extension.platform.PlatformCommandManager.handleCommand(PlatformCommandManager.java:497) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.util.eventbus.MethodHandleEventHandler.dispatch(MethodHandleEventHandler.java:51) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.util.eventbus.EventHandler.handleEvent(EventHandler.java:73) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.util.eventbus.EventBus.dispatch(EventBus.java:193) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.util.eventbus.EventBus.post(EventBus.java:181) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.worldedit.bukkit.WorldEditPlugin.onCommand(WorldEditPlugin.java:383) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at com.sk89q.bukkit.util.DynamicPluginCommand.execute(DynamicPluginCommand.java:55) ~[worldedit-bukkit-7.2.11-SNAPSHOT-dist.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R1.CraftServer.dispatchCommand(CraftServer.java:909) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.handleCommand(ServerGamePacketListenerImpl.java:2382) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$18(ServerGamePacketListenerImpl.java:2153) ~[?:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1359) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:183) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1336) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1329) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1307) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1192) ~[paper-1.19.jar:git-Paper-81]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:303) ~[paper-1.19.jar:git-Paper-81]
	at java.lang.Thread.run(Thread.java:833) ~[?:?]

Expected Behavior

No stacktrace or a friendly error message.

Reproduction Steps

  1. //pos1
  2. //pos2
  3. //copy
  4. //schem save ??

Anything Else?

No response

commented

What are you calling the schematic? It looks like windows rejected the file name as invalid, rather than any issue on WorldEdit's end

commented

Yeah, this is due to Windows not supporting files with question marks in the name

commented

The schematic had a question mark in the name. It works on my server but not on my local server.

commented

Oh, WorldEdit schould probably forbid creation of files with special characters, otherwise schematics are unusable if they are created on a Linux server and you try to use them on a local Windows server.

commented

that's not possible at all. it's not even "special characters" - windows has a dozen or so names of perfectly innocuous character strings which are invalid file names (like "CON"). special characters on one operating system or even file system might be perfectly valid on another.
basically - it's not on worldedit to filter what is or isn't a valid file name. the best we can do is return a more user-friendly error message when the underlying fs throws an error like that instead of dumping a big stacktrace in console.

commented

By that logic too, should we prevent schematics from having names with capital letters, given some file systems (such as NTFS on Windows) are case insensitive? There are way too many cases like this that differ per the dozens of file systems that are in active use. If we filtered things out, most names wouldn’t work anymore

commented

Closed by 55e2d3d