posit-dev / posit-dev/connectapi

Querying file extension by the MIME type may return multiple extensions

Open
#382 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
54
Forks
27
Avg merge
1d 3m
Merged PRs (30d)
1

Description

When multiple extensions have the same MIME type, the code here can become problematic:

https://github.com/posit-dev/connectapi/blob/67a52e20e147a9f1102ac73c73370c7498913a47/R/thumbnail.R#L53-L58

For example, image/jpeg currently corresponds to four extension in the dev version of the mime package:

library(mime)
mimemap[mimemap == 'image/jpeg']
        jfif          jpe         jpeg          jpg 
"image/jpeg" "image/jpeg" "image/jpeg" "image/jpeg" 

That means the test here will be broken (since it assumes the first extension to be .jpeg, which has become .jfif in the dev version of mime):

https://github.com/posit-dev/connectapi/blob/67a52e20e147a9f1102ac73c73370c7498913a47/tests/testthat/test-thumbnail.R#L35

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in R/thumbnail.R at the MIME-to-extension lookup and read tests/testthat/test-thumbnail.R, especially the test that assumes a particular JPEG extension. Reproduce the behavior with the current mime package, then establish a test expectation that does not depend on extension ordering and run the thumbnail tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.