Failed to validate remote image with no file extension

Created on 24 August 2019, about 5 years ago
Updated 27 February 2024, 9 months ago

Problem/Motivation

If a file to import from a URL doesn't have a file extension, Feeds fails to import it.

Sample photo without file extension

https://s4.reutersmedia.net/resources/r/?m=02&d=20160330&t=2&i=1128905435

Error messages

1) failed to validate with the following errors:
field_photo.0: Only files with the following extensions are allowed: png gif jpg jpeg.

2) failed to save because the extension AAuE7mC3_09BzkSYxsRtNA=c0x00000000-cc-rp-mo-ba5 is invalid

A sample successful user photo with file extension

https://lh3.googleusercontent.com/a-/AAuE7mC3_09BzkSYxsRtNA=c0x00000000-cc-rp-mo-ba5.jpg

Steps to reproduce

  1. Find a resource URL where a file can be downloaded but the extension isn't specified in the URL
  2. Create a feed type, map to title and to a file target.
  3. Import data like the following (CSV example):
    title,file
    Lorem Ipsum,https://s4.reutersmedia.net/resources/r/?m=02&d=20160330&t=2&i=1128905435
    

Proposed resolution

If an extension isn't specified in the url, try to determine the extension by inspecting the mime type of the file.

Remaining tasks

  1. Write tests covering the following cases:
    • Import a file with extension that is not an image.
    • Import a file without extension that is not an image.
    • Try to import a file that does not exist.
  2. Write the fix in such a way that at least test cases 1 to 3 passes. Fixing test case 4 may be handled in an other issue such as #3023198: Display an understandable error message when source file contains links to non-existing files .
💬 Support request
Status

Needs work

Version

3.0

Component

Code

Created by

🇵🇭Philippines madelyncruz

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024