Urgent.News

What's breaking now, across thousands of outlets.

Tech

Detect a GIF file before choosing its browser preview

A file called reaction.gif can still contain MP4 video. This matters in upload widgets: choosing an <img> solely from the filename can produce a broken preview, while accepting the file as a verified image can mislead later processing. A short header check can improve the error message before the application hands the bytes to a real decoder. Read a small prefix, not the whole file The following…

A GIF file may actually contain MP4 video data, impacting upload widgets. A brief header examination can provide an early error message before the application passes the bytes to a decoder. The following JavaScript function inspects the two GIF signatures and a common ISO Base Media File Format header. It does not assume the file is a playable MP4.

The six-byte GIF marker is sufficient for this classification. However, this does not confirm every block is valid or that decoding will fit the device's memory. A header check is a routing guide, not an acceptance check. Other formats using the same container family should not be misidentified as MP4. The filename and content type are separate evidences; the upload endpoint should validate the format independently.

If the header identifies an ISO BMFF, inform the user that it looks like a video container. If the kind is unknown, clarify that the file doesn't have a recognized GIF header. Otherwise, indicate a GIF header was found. Avoid assuming renaming will fix the file; changing the extension does not alter the encoding. Similarly, tools labeling looping animations as GIFs are incorrect.

Apply this distinction to saved animations. Some services, like Twitter's GIF Downloader, demonstrate converting MP4 to GIF for X animations. If a destination only accepts images, convert the file to GIF and inspect it. If the destination supports video and playback controls are useful, retain the MP4 format. The browser should only display a GIF preview if the image decoder accepts it.

A video container requires a supported video codec and container combination; the header alone cannot determine this. Server-side policies should enforce file size, decoded dimensions, resource limits, and a supported-format policy.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

What SMS and Voice Calls Give a Fall Alert That Push Notifications Cannot

Every fall-alarm article on this site ends the same way: step five is yours. The radar detects the collapse, waits out its configured delay, publishes fallStatus , and on the finished units even…

  • SMS and voice calls ensure reliable communication.
  • SMS works without device capabilities or network issues.
  • Voice calls provide immediate auditory alert.

A Practical CMS Security Review: XSS, CSRF, and SQL Injection

A CMS editor form crosses several trust boundaries. It accepts a request from a browser, changes stored records, and later displays content to readers or administrators.

  • CMS transitions from user input to rendered content, creating multiple security vulnerabilities.
  • XSS, CSRF, and SQL injection each require distinct mitigation techniques.
  • Audit case study applies to application codebase, themes, plugins, and integrations.

A brief history of just-in-time (2003)

PDF Software systems have been using "just-in-time" compilation (JIT) techniques since the 1960s. Broadly, JIT compilation includes any translation performed dynamically, after a program has started…

More from Sunday 1 November →