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

Fix for crates using custom relative license-file paths in the Cargo.toml. #46

Merged
merged 1 commit into from
Nov 22, 2019
Merged

Fix for crates using custom relative license-file paths in the Cargo.toml. #46

merged 1 commit into from
Nov 22, 2019

Conversation

foresterre
Copy link
Contributor

There are currently two ways which this crate uses to discover license
files.

The first method searches for paths starting with "LICENSE"
in the root of the current crate.
The second, uses a path specified by a crate author (in the Cargo.toml,
under the package table, a license-file can be specified).

The paths collected by the first method are absolute.
The path collected by the second is, however, relative to the crate.

The program however expects the paths to be absolute. For example,
in 'get_expression()', paths will be made relative by using the
'strip_prefix' method on the path. If the path is already relative,
as was the case before this commit, the program crashes.

Now perhaps the bug can also be fixed by making all paths relative,
however since I'm not well acquainted with the code base it is difficult
to make such a judgement, and as such this fix seemed safer to me.

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Changes the license-file as specified by a crate author to be used internally as an absolute path instead of a relative path.

I'd like them included because I use these kinds of paths in my sic program and would like to keep using them. I discover the bug while attempting to run cargo-deny on the CI.

Related Issues

issue: #45

A license-file which didn't start with LICENSE was not handled correctly.

There are currently two ways which this crate uses to discover license
files.

The first method searches for paths starting with "LICENSE"
in the root of the current crate.
The second, uses a path specified by a crate author (in the Cargo.toml,
under the package table, a license-file can be specified).

The paths collected by the first method are absolute.
The path collected by the second however is relative to the crate.

The program however expects the paths to be absolute. For example,
in 'get_expression()', paths will be made relative by using the
'strip_prefix' method on the path. If the path is already relative,
as was the case before this commit, the program crashes.

Now perhaps the bug can also be fixed by making all paths relative,
however since I'm not well acquainted with the code base it is difficult
to make such a judgement, and as such this fix seemed safer to me.
Copy link
Member

@Jake-Shadle Jake-Shadle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for the PR!

@Jake-Shadle Jake-Shadle merged commit cf45872 into EmbarkStudios:master Nov 22, 2019
Jake-Shadle added a commit that referenced this pull request Nov 28, 2019
Jake-Shadle added a commit that referenced this pull request Nov 28, 2019
* Fix binary_search_by_name out of bounds panic
* Add CHANGELOG note
* Add CHANGELOG note for #46
* Update dependencies
* Prepare 0.4.1
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