Skip to content

Version containment algorithm is incorrect in case of single inequality #54

@manueljacob

Description

@manueljacob

For a version range with a single equality (e.g. vers:semver/>=1.0.0), the algorithm described in Checking if a version is contained within a range will not do an iteration in step “iterate over the current and next contiguous constraints pairs (aka. pairwise) in the second list” because there is no pair in a list of one element. Therefore, the algorithm considers no version (if the inequality uses < or >) or exactly one version (if the inequality uses <= or >=) to be in the version range.

A possible fix would be to

  • pull the step “If this is the first iteration and current comparator is "<" or <=" and the "tested version" is less than the current version then the "tested version" is IN the range. Check is finished.” out of the loop body and change it to “If the first comparator is "<" or <=" and the "tested version" is less than the first version then the "tested version" is IN the range. Check is finished.”
  • pull the step “If this is the last iteration and next comparator is ">" or >=" and the "tested version" is greater than the next version then the "tested version" is IN the range. Check is finished.” out of the loop body and change it to “If the last comparator is ">" or >=" and the "tested version" is greater than the last version then the "tested version" is IN the range. Check is finished.”

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions