1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

isAllowedURI: Format

(cherry picked from commit 1fa958dda1)
This commit is contained in:
Robert Hensing 2023-12-06 14:08:22 +01:00
parent ec5e4041ba
commit 4795569bf7

View file

@ -657,11 +657,14 @@ bool isAllowedURI(std::string_view uri, const Strings & allowedUris)
prefix. Thus, the prefix https://github.co does not permit
access to https://github.com. */
for (auto & prefix : allowedUris) {
if (uri == prefix ||
(uri.size() > prefix.size()
if (uri == prefix
// Allow access to subdirectories of the prefix.
|| (uri.size() > prefix.size()
&& prefix.size() > 0
&& hasPrefix(uri, prefix)
&& (prefix[prefix.size() - 1] == '/' || uri[prefix.size()] == '/')))
&& (
prefix[prefix.size() - 1] == '/'
|| uri[prefix.size()] == '/')))
return true;
}