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

Fixed bug with WAV file wrongly parsed as MP3 #240

Merged
merged 9 commits into from
Aug 24, 2023

Conversation

CostinTanasoiu
Copy link
Contributor

@CostinTanasoiu CostinTanasoiu commented Aug 22, 2023

This happened when parsing files without passing a filename hint, hence relying only on the file bytes. The MP3 format is loose and the MP3 parser is prone to false positives, but hopefully the following fixes will prevent this from happening for any of the file types for which we have registered parsers.

  • Changed MP3 priority from 99 to 101. This ensures that MP3 parser is the last one to be used when we're iterating through parsers.
  • Added a preventive check against WAV headers in the MP3 parser
  • Added a new test verifying that we correctly parse files over HTTP even without a filename hint
  • Added a test verifying that MP3 is always the last parser used when not providing a filename hint
  • Set up a new convention that invalid fixtures contain the "invalid" word in their filename and added tests for this
  • Updated some fixture names

- Changed MP3 priority from 99 to 101
- Added a preventive check against WAV headers in the MP3 parser
- Added a new test that ensures we correctly parse files over HTTP even when not providing a filename hint
- Added a test verifying that MP3 is always the last parser used when not providing a filename hint
- Updated some fixture names
lib/parsers/mp3_parser.rb Show resolved Hide resolved
spec/format_parser_spec.rb Outdated Show resolved Hide resolved
spec/remote_fetching_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@rcpalacio rcpalacio left a comment

Choose a reason for hiding this comment

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

👍

lib/format_parser.rb Outdated Show resolved Hide resolved
@CostinTanasoiu CostinTanasoiu merged commit a8a4d07 into master Aug 24, 2023
12 checks passed
@CostinTanasoiu CostinTanasoiu deleted the bugfix-wav-as-mp3 branch August 24, 2023 14:03
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.

None yet

3 participants