Re: Sphere path escapes
Reply #3 –
So I did a few tests.
function game()
{
var sound = LoadSound('<fill in path>/Munch.wav')
sound.play(true);
while (true) FlipScreen();
}
- What does `./` do?
Nothing. Specifically, prefixing a filename with a dot-slash is the same as no prefix at all. This means the engine either A) treats the default directory for the requested resource as the current directory, or B) Canonizes the filename into an absolute path and opens that. minisphere does the latter, and from what I saw in the Sphere source, I believe it does the former. SSFML, however, is an oddball: No error, but no sound either.
- What does `/path` do?
Sphere 1.5 - "Invalid filename". This is a sandbox violation so Sphere will have none of it. minisphere errors out as well as the filename fails the relative-path requirement. SSFML again provides to be an odd duck here: It loads the file from <game_dir>/sounds!
- How much canonization happens? Would ~/../[game folder name]/ work?
In Sphere 1.5, that would be a resounding "No". Invalid filename again--it treats it as a sandbox violation. minisphere and SSFML both play the sound.
- Bonus test: ../../../../../../Munch.wav (taking the long way to root)
Sphere 1.5: Sandbox violation again. I have to say I'm impressed, this thing is built like Fort Knox! minisphere: Sound plays. SSFML: Sound plays.
- Bonus test #2: Symlink to external directory
And the mighty Sphere 1.5 falls! The sound plays; even its sandbox isn't enough to deal with this level of shenanigans. Naturally, minisphere and SSFML both succeed in playing the sound as well.