From 49a35a4eee8fb4efa1bb0c111167bfd4e1bb78d6 Mon Sep 17 00:00:00 2001 From: Iwona Just Date: Wed, 4 Sep 2024 15:10:52 +0100 Subject: [PATCH 1/2] if we don't have extension, don't add a full stop to the filename --- src/fields/Assets.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/fields/Assets.php b/src/fields/Assets.php index 09978fed..e8126bcf 100644 --- a/src/fields/Assets.php +++ b/src/fields/Assets.php @@ -181,7 +181,14 @@ public function parseField(): mixed $urlsToUpload[$key]['value'] = $dataValue; if (isset($filenamesFromFeed[$key])) { - $filename = $filenamesFromFeed[$key] . '.' . AssetHelper::getRemoteUrlExtension($urlsToUpload[$key]['value']); + $filename = $filenamesFromFeed[$key]; + + // if we can determine the extension of the remote file, use that extension + $remoteUrlExtension = AssetHelper::getRemoteUrlExtension($urlsToUpload[$key]['value']); + if (!empty($remoteUrlExtension)) { + $filename .= '.' . $remoteUrlExtension; + } + $urlsToUpload[$key]['newFilename'] = $filename; } else { $filename = AssetHelper::getRemoteUrlFilename($dataValue); From d75a3a813a7d4bd3e5c85afdca42915864b37252 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Wed, 25 Sep 2024 16:45:22 -0700 Subject: [PATCH 2/2] changelog for https://github.com/craftcms/feed-me/pull/1506 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b31672b..58114037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Release Notes for Feed Me +## Unreleased + +- Fixed a bug that could occur when uploading files to an Assets field from an external URL and a new filename is provided, but we can't determine the remote file's extension. ([#1506](https://github.com/craftcms/feed-me/pull/1506)) + ## 5.7.0 - 2024-08-14 - Added a `feed-me/logs/clear` console command to clear database logs.