python-adfs
changeset 46:75a84b1d21da
Found a problem with disc titles containing control characters (\x00 in
particular) on disc images sent by Simon Brooke <simon@jasmine.org.uk>.
The problem was introduced by the old format disc catalogue reading method
"read_old_catalogue" which uses the directory title of the sector whose
parent is itself as the disc name. No control code stripping was done and
it turned out that the "safe" method needed extending to allow spaces for
this purpose since they appear to be valid characters in disc titles.
| author | David Boddie <david@boddie.org.uk> |
|---|---|
| date | Wed Jul 02 23:17:26 2003 +0200 |
| parents | c7dac854aca5 |
| children | 3d237df4bd0b |
| files | ADFSlib.py |
| diffstat | 1 files changed, 13 insertions(+), 4 deletions(-) [+] |
line diff
1.1 --- a/ADFSlib.py Tue May 20 03:09:45 2003 +0200 1.2 +++ b/ADFSlib.py Wed Jul 02 23:17:26 2003 +0200 1.3 @@ -551,11 +551,16 @@ 1.4 return s 1.5 1.6 1.7 - def safe(self, s): 1.8 + def safe(self, s, with_space = 0): 1.9 1.10 new = "" 1.11 + if with_space == 1: 1.12 + lower = 31 1.13 + else: 1.14 + lower = 32 1.15 + 1.16 for i in s: 1.17 - if ord(i) <= 32: 1.18 + if ord(i) <= lower: 1.19 break 1.20 1.21 if ord(i) >= 128: 1.22 @@ -564,7 +569,7 @@ 1.23 new = new + chr(c) 1.24 else: 1.25 new = new + i 1.26 - 1.27 + 1.28 return new 1.29 1.30 1.31 @@ -757,7 +762,11 @@ 1.32 ) 1.33 1.34 if parent == head: 1.35 - self.disc_name = dir_title 1.36 + 1.37 + # Use the directory title as the disc name. 1.38 + 1.39 + # Note that the title may contain spaces. 1.40 + self.disc_name = self.safe(dir_title, with_space = 1) 1.41 1.42 # print "Directory title", dir_title 1.43 # print "Directory name ", dir_name
