mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-16 14:47:49 -06:00
fix: refuse drive segments in manifest paths
A drive is refused only at the start of a value, so a later segment such as ../C:x joins as a drive-relative path on Windows. Every manifest path now refuses a segment Windows reads as a drive and one ending with a colon. roms_directory, emulators_directory and the dests below them refuse any colon. Elsewhere a colon inside a name is kept where the host is not Windows: RetroDECK's ares reads bios/snes:st018.data.rom and bios/zxs:48.rom on Linux, three dests of install/retrodeck.json. A Windows host refuses them as alternate data streams. The roms root is also checked to stay below the BIOS folder's ancestor it climbs to.
This commit is contained in:
1 parent
10ca8523b5
commit
39778a7359
5 files changed
+78
-24
No files matched your search
@@ -1184,6 +1184,34 @@ class OuterRootsAreUntrusted(unittest.TestCase):
|
||||
with self.subTest(field=field, value=value), self.assertRaises(ValueError):
|
||||
install._check_emulators_directory({"emulators_directory": layout})
|
||||
|
||||
def test_a_drive_or_colon_segment_is_refused_on_either_host(self):
|
||||
from pathlib import PureWindowsPath
|
||||
|
||||
bios = PureWindowsPath("C:/RetroBat/bios")
|
||||
for host in ("posix", "nt"):
|
||||
with unittest.mock.patch.object(install.os, "name", host):
|
||||
for value in ("../C:x", "..\\x", "../x:", "../Roms:x"):
|
||||
with self.subTest(host=host, from_bios=value), self.assertRaises(ValueError):
|
||||
install._check_roms_directory(
|
||||
{"roms_directory": {**self.ROMS, "from_bios": value}})
|
||||
for value in ("C:x/{key}", "x:/{key}", "emu:x/{key}"):
|
||||
layout = {**self.EMULATORS, "searched": [value], "default": value}
|
||||
with self.subTest(host=host, searched=value), self.assertRaises(ValueError):
|
||||
install._check_emulators_directory({"emulators_directory": layout})
|
||||
for dest in ("bios/C:x.bin", "bios/x:", "a:b/c.bin"):
|
||||
with self.subTest(host=host, dest=dest), self.assertRaises(ValueError):
|
||||
install._safe_relative_path(dest, "dest")
|
||||
with self.subTest(host=host), self.assertRaises(ValueError):
|
||||
install._safe_relative_path("pico8/x:y", "dest", colons=False)
|
||||
# Each of these leaves the folder on Windows once joined.
|
||||
self.assertEqual(PureWindowsPath(bios, "..", "D:x"), PureWindowsPath("D:x"))
|
||||
self.assertEqual(PureWindowsPath("C:x").drive, "C:")
|
||||
# RetroDECK's ares names are kept where the host is not Windows.
|
||||
with unittest.mock.patch.object(install.os, "name", "posix"):
|
||||
install._safe_relative_path("bios/snes:st018.data.rom", "dest")
|
||||
with unittest.mock.patch.object(install.os, "name", "nt"), self.assertRaises(ValueError):
|
||||
install._safe_relative_path("bios/snes:st018.data.rom", "dest")
|
||||
|
||||
def test_an_emulator_folder_stays_below_the_platform_folder(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
home = Path(tmp)
|
||||
|
||||
Reference in new issue
Block a user