I've found an odd case:
readme path is relative pointing to a parent directory: ../README.md,README.md in the .crate file,It seems the readme was snatched when the crate was published, with whatever filesystem access was temporarily possible at time of publishing. Unfortunately, it means it's not possible to get the README later from the package.
Could Cargo require the README to be in the package?
What should be done for this case? It's just a bit of an odd one.
A simple client-side fix to Cargo would be:
readme path and check that it doesn't escape crate's root (root.join(readme).strip_prefix(root).is_some() perhaps?)include key, perhaps add it there, or warn if it's excluded.Or rendering of README's could be moved to server-side. The server would read them from the actual package, so that authors would be visible when the package is incomplete.
Yeah, there's a few different ways cargo could be more consistent, the whole spectrum from hard erroring, to warning, to accommodating. I'm just not sure what we prefer. 馃檪
Mildly related, on publishing and README checking: #4861
In #6607 @ehuss suggests this fix:
copy the README somewhere into the package and rewrite the path in Cargo.toml
I have just run into this issue. I think that it would be great if cargo could deal with it copying files outside of the crate directory, but in the meantime it would be nice to have a warning (personally I would prefer an error).
Most helpful comment
In #6607 @ehuss suggests this fix: