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

Reject invalid Debian version values. #1971

Merged
merged 2 commits into from
Dec 4, 2022
Merged

Reject invalid Debian version values. #1971

merged 2 commits into from
Dec 4, 2022

Conversation

jordansissel
Copy link
Owner

This fixes #1847 by adding an actionable error message when someone provides a version value that Debian's policy and tools will reject.

Includes test coverage :)

A hopefully-actionable error message is provided when an invalid version
is given when making a Debian package.

To aid readability, rewrote the relationship pattern as a multiline regex. Added separate pattern for version field.

Test coverage added for #1969's "v" prefix removal.

For #1847
@jordansissel jordansissel marked this pull request as ready for review December 4, 2022 02:15
@jordansissel
Copy link
Owner Author

% bundle exec rspec spec/fpm/package/deb_spec.rb

Finished in 4.25 seconds (files took 0.61127 seconds to load)
70 examples, 0 failures

Specific new tests:

FPM::Package::Deb
  when validating the version field
    should reject as invalid, '_'
    should reject as invalid, '1_2'
    should reject as invalid, 'abc def'
    should reject as invalid, '%'
    should reject as invalid, '1^a'
    should accept '1'
    should remove a leading 'v' from v1 and still accept it
    should accept '1.2'
    should remove a leading 'v' from v1.2 and still accept it
    should accept '1.2.3'
    should remove a leading 'v' from v1.2.3 and still accept it
    should accept '20200101'
    should remove a leading 'v' from v20200101 and still accept it
    should accept '1~beta'
    should remove a leading 'v' from v1~beta and still accept it
    should accept '1whatever'
    should remove a leading 'v' from v1whatever and still accept it

Finished in 0.01125 seconds (files took 0.61874 seconds to load)
17 examples, 0 failures

@gliptak
Copy link
Contributor

gliptak commented Dec 4, 2022

#1970

@jordansissel jordansissel merged commit 3150610 into main Dec 4, 2022
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.

Reject invalid version strings for debian packages.
2 participants