Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw WARNING when encountering non-standard file extensions for common document encoding types #635

Merged
merged 7 commits into from
May 5, 2023

Conversation

al-niessner
Copy link
Contributor

@al-niessner al-niessner commented May 1, 2023

🗒️ Summary

Added a check that compares the file extension (suffix of filename from last .) to the those known or allowed for the given encoding type, When it fails it generates the following message:

WARNING  [error.validation.file_naming_problem]   From the encoding type 'PNG'the file extension 'jpg' is not one of the allowed: [png]

⚙️ Test Data and/or Report

See unit testing below

♻️ Related Issues

Closes #617

@sonatype-lift
Copy link
Contributor

sonatype-lift bot commented May 1, 2023

🛠 Lift Auto-fix

Some of the Lift findings in this PR can be automatically fixed. You can download and apply these changes in your local project directory of your branch to review the suggestions before committing.1

# Download the patch
curl https://lift.sonatype.com/api/patch/github.com/NASA-PDS/validate/635.diff -o lift-autofixes.diff

# Apply the patch with git
git apply lift-autofixes.diff

# Review the changes
git diff

Want it all in a single command? Open a terminal in your project's directory and copy and paste the following command:

curl https://lift.sonatype.com/api/patch/github.com/NASA-PDS/validate/635.diff | git apply

Once you're satisfied, commit and push your changes in your project.

Footnotes

  1. You can preview the patch by opening the patch URL in the browser.

Al Niessner added 2 commits May 1, 2023 15:08
Verify the file extension or suffix matches those expected for the given encoding type. An enumeration (table) is used to make the XML encoding type to a list of allowed extensions for the encoding type. The enumeration is the only thing that needs changed when new encoding types are added or list of the extensions is expanded.
@al-niessner al-niessner marked this pull request as ready for review May 2, 2023 15:50
@al-niessner
Copy link
Contributor Author

@jordanpadams @nutjob4life @tloubrieu-jpl

Ready for review. Can sonatype be run again?

Copy link
Member

@nutjob4life nutjob4life left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jordanpadams jordanpadams changed the title issue 617: match extensions to expected MIME types Throw WARNING when encountering non-standard file extensions for common document encoding types May 5, 2023
@jordanpadams jordanpadams merged commit fb08b93 into main May 5, 2023
@jordanpadams jordanpadams deleted the issue_617 branch May 5, 2023 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a user, I would like to enforce browse file extension with encoding type
3 participants