Skip to content

Commit

Permalink
Fix hyphen-in-path bug in ImportLokaliseCommand. (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Sep 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3b57baa commit 33e5937
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -138,15 +138,20 @@ protected function matchTargetFiles(string $sourceDir, string $targetDir, array
if (!file_exists($targetFile)) {
$parts = explode('-', $targetFile);
if (count($parts) > 1) {
array_pop($parts);
$revisedTargetFile = implode('-', $parts) . '.ini';
$matchingSourceFile = preg_replace(
'/^' . preg_quote($targetDir, '/') . '/',
$sourceDir,
$revisedTargetFile
);
if (!in_array($matchingSourceFile, $sourceFiles)) {
$targetFile = $revisedTargetFile;
$lastPart = array_pop($parts);
// If there's a slash in the last part, this means there's a hyphen
// in a directory name somewhere. We should only process further if
// the hyphen is in the FILENAME.
if (!str_contains($lastPart, '/')) {
$revisedTargetFile = implode('-', $parts) . '.ini';
$matchingSourceFile = preg_replace(
'/^' . preg_quote($targetDir, '/') . '/',
$sourceDir,
$revisedTargetFile
);
if (!in_array($matchingSourceFile, $sourceFiles)) {
$targetFile = $revisedTargetFile;
}
}
}
}

0 comments on commit 33e5937

Please sign in to comment.