Can't open files with two consecutive periods in name

I received a comment on my app Pocket Reader:

I found a reproducible crash: if a filename has two periods between the name and extension it will crash the Playdate (file..txt). I made a typo when creating files to read.

I have confirmed that file.listFiles will list such files, but file.open and datastore.read will both return nil. This is true for consecutive periods anywhere in the file name.

One of those times where I wonder: do you even want this fixed? Is it a valid filename? Would you rather find out you made a typo or let that typo live on and confuse you or anyone else later?

Instead, you might check for nil and show an "invalid filename" error message

1 Like

My thinking is that if it's valid on your computer it should probably be valid on your Playdate as well. If people want ellipses in their filenames I don't think it's my job to say no, and it's not like I'm checking for other typos so that thinking is a bit weird to me. I also think if file.listFiles says it's a file then it should be possible to open it.

I'll leave it for Panic to decide though, this is just how I see it, and there might be some limitation I'm not aware of.

I think the main limitation is preventing devs to access files outside of their sandbox by using paths like:

myfolder/../../folder.of.an.other.game/file

Sure, but it'd be enough to block paths with ../ instead of paths with .. for that reason, right?

1 Like