about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T01·19+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T01·19+0100
commitb99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (patch)
tree1f76047dd027421dcf79cdf4804fa5ff1bb08b2b /third_party/nix/src/libexpr/eval.cc
parent8cf1322a6fd5ae282d8a09fdba634f27a1a88560 (diff)
refactor(3p/nix/libutil): Replace hasPrefix/Suffix with Abseil r/845
Uses the equivalent absl::StartsWith and absl::EndsWith functions
instead.
Diffstat (limited to 'third_party/nix/src/libexpr/eval.cc')
-rw-r--r--third_party/nix/src/libexpr/eval.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index d93f39bba4..ca2b65203f 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -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;
   }