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

mediafile._safe_cast: be safer when converting to int #2741

Merged
merged 1 commit into from
Nov 19, 2017

Conversation

eigengrau
Copy link
Contributor

The regex «[+-]?[0-9]*» possibly matches a single minus/plus, which was then
passed on to int, raising a ValueError from within _safe_cast. The test suite
covered this for float, but not for int.

We now make sure we actually have a number after the sign by using a Kleene
plus.

@sampsyo
Copy link
Member

sampsyo commented Nov 19, 2017

Looks great; thank you for catching this! Would you mind writing a changelog entry describing what could go wrong (i.e., a ValueError would occur when a number was just + or just -)?

The regex «[\+-]?[0-9]*» possibly matches a single minus/plus, which would then
be passed on to int(), raising a ValueError from within _safe_cast. The test
suite covered this for float, but not for int.

We now make sure we actually have a number after the sign by using a Kleene
plus.
@eigengrau
Copy link
Contributor Author

Thanks! Amended.

@sampsyo sampsyo merged commit c40ea4f into beetbox:master Nov 19, 2017
sampsyo added a commit that referenced this pull request Nov 19, 2017
mediafile._safe_cast: be safer when converting to int
sampsyo added a commit that referenced this pull request Nov 19, 2017
@sampsyo
Copy link
Member

sampsyo commented Nov 19, 2017

Thanks again!! I've merged the fix.

@eigengrau
Copy link
Contributor Author

Thank you for making beets!

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.

2 participants