Skip to content

Fixed bug with WAV file wrongly parsed as MP3#240

Merged
CostinTanasoiu merged 9 commits intomasterfrom
bugfix-wav-as-mp3
Aug 24, 2023
Merged

Fixed bug with WAV file wrongly parsed as MP3#240
CostinTanasoiu merged 9 commits intomasterfrom
bugfix-wav-as-mp3

Conversation

@CostinTanasoiu
Copy link
Copy Markdown
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
Comment thread spec/remote_fetching_spec.rb Outdated
Comment thread spec/remote_fetching_spec.rb Outdated
Comment thread spec/remote_fetching_spec.rb Outdated
Comment thread spec/format_parser_spec.rb Outdated
Comment thread lib/parsers/mp3_parser.rb
Comment thread spec/format_parser_spec.rb Outdated
Comment thread spec/remote_fetching_spec.rb Outdated
Copy link
Copy Markdown
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.

👍

Comment thread lib/format_parser.rb Outdated
@CostinTanasoiu CostinTanasoiu merged commit a8a4d07 into master Aug 24, 2023
@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.

3 participants