refactor(3p/nix/libutil): Replace hasPrefix/Suffix with Abseil

Uses the equivalent absl::StartsWith and absl::EndsWith functions
instead.
This commit is contained in:
Vincent Ambo 2020-05-25 02:19:01 +01:00
parent 8cf1322a6f
commit b99b368d17
21 changed files with 69 additions and 57 deletions

View file

@ -7,6 +7,7 @@
#include <iostream>
#include <new>
#include <absl/strings/match.h>
#include <gc/gc.h>
#include <gc/gc_cpp.h>
#include <glog/logging.h>
@ -423,7 +424,7 @@ void EvalState::checkURI(const std::string& uri) {
for (auto& prefix : evalSettings.allowedUris.get()) {
if (uri == prefix ||
(uri.size() > prefix.size() && !prefix.empty() &&
hasPrefix(uri, prefix) &&
absl::StartsWith(uri, prefix) &&
(prefix[prefix.size() - 1] == '/' || uri[prefix.size()] == '/'))) {
return;
}
@ -431,12 +432,12 @@ void EvalState::checkURI(const std::string& uri) {
/* If the URI is a path, then check it against allowedPaths as
well. */
if (hasPrefix(uri, "/")) {
if (absl::StartsWith(uri, "/")) {
checkSourcePath(uri);
return;
}
if (hasPrefix(uri, "file://")) {
if (absl::StartsWith(uri, "file://")) {
checkSourcePath(std::string(uri, 7));
return;
}