mirror of
https://github.com/brouhaha/sosar.git
synced 2025-08-05 10:25:00 +00:00
Validate filenames, and convert them to lower case.
This commit is contained in:
11
sosdisk.py
11
sosdisk.py
@@ -1,3 +1,4 @@
|
|||||||
|
import string
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -43,6 +44,14 @@ interleave_tables = { 'dos': dos_to_phys_sect,
|
|||||||
'sos': half_block_to_phys_sect }
|
'sos': half_block_to_phys_sect }
|
||||||
|
|
||||||
|
|
||||||
|
sos_valid_fn_chars = set(string.ascii_uppercase + string.digits + '.')
|
||||||
|
|
||||||
|
def bytes_to_sos_filename(b):
|
||||||
|
s = str(b, 'ascii')
|
||||||
|
assert all(c in sos_valid_fn_chars for c in s)
|
||||||
|
return s.lower()
|
||||||
|
|
||||||
|
|
||||||
class SOSDirectoryEntry:
|
class SOSDirectoryEntry:
|
||||||
def __init__(self, disk):
|
def __init__(self, disk):
|
||||||
self.disk = disk
|
self.disk = disk
|
||||||
@@ -78,7 +87,7 @@ class SOSFileEntry(SOSDirectoryEntry):
|
|||||||
self.storage >>= 4
|
self.storage >>= 4
|
||||||
if self.storage == 0:
|
if self.storage == 0:
|
||||||
return
|
return
|
||||||
self.name = str(entry_data[1:1+name_length], 'ascii')
|
self.name = bytes_to_sos_filename(entry_data[1:1+name_length])
|
||||||
if (self.storage == 0xd):
|
if (self.storage == 0xd):
|
||||||
self.subdir = SOSDirectory(disk, self.key_pointer)
|
self.subdir = SOSDirectory(disk, self.key_pointer)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user