Skip to content

Commit 4fa6355

Browse files
committed
Enforce writing the 11th field name character as null-terminator, incl new tests
Previously field names that exceeded the 10 character limit were capped and written as the first 11 characters, although it should be capped to the first 10 characters and ended with a null-terminator. See #2.
1 parent c68b256 commit 4fa6355

15 files changed

+22
-1
lines changed

shapefile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ def __dbfHeader(self):
16281628
name, fieldType, size, decimal = field
16291629
name = b(name, self.encoding, self.encodingErrors)
16301630
name = name.replace(b' ', b'_')
1631-
name = name.ljust(11).replace(b' ', b'\x00')
1631+
name = name[:10].ljust(11).replace(b' ', b'\x00')
16321632
fieldType = b(fieldType, 'ascii')
16331633
size = int(size)
16341634
fld = pack('<11sc4xBB14x', name, fieldType, size, decimal)

shapefiles/test/balancing.dbf

0 Bytes
Binary file not shown.

shapefiles/test/contextwriter.dbf

0 Bytes
Binary file not shown.

shapefiles/test/dtype.dbf

0 Bytes
Binary file not shown.

shapefiles/test/line.dbf

0 Bytes
Binary file not shown.

shapefiles/test/linem.dbf

0 Bytes
Binary file not shown.

shapefiles/test/linez.dbf

0 Bytes
Binary file not shown.

shapefiles/test/multipatch.dbf

0 Bytes
Binary file not shown.

shapefiles/test/multipoint.dbf

0 Bytes
Binary file not shown.

shapefiles/test/onlydbf.dbf

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)