summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Factories/EncodingFactory.php6
-rw-r--r--tests/app/Factories/EncodingFactoryTest.php13
2 files changed, 15 insertions, 4 deletions
diff --git a/app/Factories/EncodingFactory.php b/app/Factories/EncodingFactory.php
index fa522f9065..dc49b91a7e 100644
--- a/app/Factories/EncodingFactory.php
+++ b/app/Factories/EncodingFactory.php
@@ -148,12 +148,10 @@ class EncodingFactory implements EncodingFactoryInterface
}
if (preg_match('/1 CHAR (.+)/', $header, $match) === 1) {
- $charset = $match[1];
- } else {
- $charset = '???';
+ throw new InvalidGedcomEncodingException($match[1]);
}
- throw new InvalidGedcomEncodingException($charset);
+ return $this->make(ASCII::NAME);
}
/**
diff --git a/tests/app/Factories/EncodingFactoryTest.php b/tests/app/Factories/EncodingFactoryTest.php
index d7dc07fac0..7cd6cc53cb 100644
--- a/tests/app/Factories/EncodingFactoryTest.php
+++ b/tests/app/Factories/EncodingFactoryTest.php
@@ -96,6 +96,19 @@ class EncodingFactoryTest extends TestCase
}
/**
+ * @covers \Fisharebest\Webtrees\Factories\EncodingFactory::detect
+ */
+ public function testMissingCharHeader(): void
+ {
+ $factory = new EncodingFactory();
+
+ static::assertInstanceOf(
+ ASCII::class,
+ $factory->detect("0 HEAD\n0 TRLR")
+ );
+ }
+
+ /**
* @covers \Fisharebest\Webtrees\Factories\EncodingFactory::make
*/
public function testMake(): void