Skip to content

Commit f1290a6

Browse files
committed
handle malformed json
1 parent 234241c commit f1290a6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/GettextPOGenerator.php

+3
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ private function addStringsFromJsonFiles($translations) {
165165
// Load each JSON file to get source strings
166166
foreach ($this->JsonFiles() as $jsonFile) {
167167
$jsonTranslations = json_decode(file_get_contents($jsonFile), true);
168+
if (!is_array($jsonTranslations)) {
169+
throw new \Exception("The file '$jsonFile' is not valid JSON.'");
170+
}
168171

169172
foreach ($jsonTranslations as $key => $value) {
170173
$sourceStrings[] = $key;

0 commit comments

Comments
 (0)