Giter VIP home page Giter VIP logo

Comments (4)

billmalarky avatar billmalarky commented on July 30, 2024 1

Alternatively if no extension is set on url, fallback to determining ext from content/type http header.

Added this functionality in 1.3.0. 21fd653

from react-native-image-cache-hoc.

billmalarky avatar billmalarky commented on July 30, 2024

It has rather naive file extension validation associated with the passed in url.

https://github.com/billmalarky/react-native-image-cache-hoc/blob/master/lib/FileSystem.js#L139

I'll update it to strip the query string as well as a quick patch, but the real solution is validating the actual downloaded file as a jpg/gif/png instead of validating using a file name extension (which doesn't even necessarily mean the file is what it says it is).

Or maybe I should remove this validation from the library entirely and leave validation up to the developer who integrates the library since true file validation will incur a slight performance hit.

Update: Recalling now the extension is required to be pulled and then set to local file hash filename extension, so this logic has nothing to do with mime type validation.

Patch could involve updating file extension extraction with a url parses to get a clean path to pull ext from:

https://www.npmjs.com/package/url-parse

Alternatively if no extension is set on url, fallback to determining ext from content/type http header.

While I'm here I may as well include bmp in the allowed types since native <Image> supports bmp.

The currently supported formats are png, jpg, jpeg, bmp, gif, webp (Android only), psd (iOS only).

https://facebook.github.io/react-native/docs/image.html

from react-native-image-cache-hoc.

mtford90 avatar mtford90 commented on July 30, 2024

@billmalarky I think stripping the query string to grab the file extension is a decent short term solution - still need the query string when actually fetching the image though.

There will almost certainly be a case whereby the file extension isn't in the URL. Like you said I don't think this library should be solving file type validation.

from react-native-image-cache-hoc.

billmalarky avatar billmalarky commented on July 30, 2024

Patched in: 0c690b0

Deployed in version 1.2.3

from react-native-image-cache-hoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.