Skip to content

Commit 88edee5

Browse files
committed
Test loading corrupted file
Signed-off-by: Michal Čihař <[email protected]>
1 parent dd0cc84 commit 88edee5

File tree

3 files changed

+2
-1
lines changed

3 files changed

+2
-1
lines changed

data/invalid-shp.shp

1.3 KB
Binary file not shown.

src/ShapeFile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private function _deleteRecordFromDBF($index) {
279279
}
280280

281281
private function _loadHeaders() {
282-
if (Util::loadData('N', $this->readSHP(4)) != 9994) {
282+
if (Util::loadData('N', $this->readSHP(4)) != 0x270a) {
283283
$this->setError('Not a SHP file (file code mismatch)');
284284
return false;
285285
}

tests/ShapeFileTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public function provideErrorFiles()
9191
$result = array(
9292
array('data/no-shp.*'),
9393
array('data/missing.*'),
94+
array('data/invalid-shp.*'),
9495
);
9596

9697
if (ShapeFile::supports_dbase()) {

0 commit comments

Comments
 (0)