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

Make ProjectMedia.set_original_claim work as expected for a video URL with arguments #2040

Merged

Conversation

caiosba
Copy link
Contributor

@caiosba caiosba commented Sep 17, 2024

Description

This PR fixes a bug with ProjectMedia.set_original_claim attribute for video URLs that contained arguments, for example: https://test.xyz/video.mp4?foo=bar. The item wouldn't be created, since the extension validation would fail.

The fix is to use File.extname over the URL path only, not the full URL, since the former strips the arguments, while the latter contains them.

Fixes: CV2-5232.

How has this been tested?

TDD. I was able to reproduce the bug in a unit test contained in this PR. The test passed once the fix was implemented.

Things to pay attention to during code review

At some point, we may get rid of File.extname altogether and instead rely on the content-type response header in order to extract the extension.

Checklist

  • I have performed a self-review of my own code
  • I have added unit and feature tests, if the PR implements a new feature or otherwise would benefit from additional testing
  • I have added regression tests, if the PR fixes a bug
  • I have added logging, exception reporting, and custom tracing with any additional information required for debugging
  • I considered secure coding practices when writing this code. Any security concerns are noted above.
  • I have commented my code in hard-to-understand areas, if any
  • I have made needed changes to the README
  • My changes generate no new warnings
  • If I added a third party module, I included a rationale for doing so and followed our current guidelines

…URL with arguments.

This PR fixes a bug with `ProjectMedia.set_original_claim` attribute for video URLs that contained arguments, for example: https://test.xyz/video.mp4?foo=bar. The item wouldn't be created, since the extension validation would fail.

The fix is to use `File.ext` over the URL path, not the full URL, since the former strips the arguments, while the latter contains them.

Fixes: CV2-5232.
@caiosba caiosba changed the title Make ProjectMedia.set_original_claim works as expected for a video URL with arguments Make ProjectMedia.set_original_claim work as expected for a video URL with arguments Sep 17, 2024
@caiosba caiosba merged commit dd49775 into develop Sep 18, 2024
9 of 10 checks passed
@caiosba caiosba deleted the fix/CV2-5232-set-original-claim-media-from-url-with-arguments branch September 18, 2024 02:14
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