about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/libexpr')
-rw-r--r--third_party/nix/src/libexpr/eval.cc7
-rw-r--r--third_party/nix/src/libexpr/primops/fetchGit.cc8
-rw-r--r--third_party/nix/src/libexpr/primops/fetchMercurial.cc7
3 files changed, 13 insertions, 9 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;
   }
diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc
index c450907077..99f1c3c4ba 100644
--- a/third_party/nix/src/libexpr/primops/fetchGit.cc
+++ b/third_party/nix/src/libexpr/primops/fetchGit.cc
@@ -2,6 +2,7 @@
 #include <regex>
 
 #include <absl/strings/ascii.h>
+#include <absl/strings/match.h>
 #include <glog/logging.h>
 #include <sys/time.h>
 
@@ -31,7 +32,8 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
   if (evalSettings.pureEval && rev == "")
     throw Error("in pure evaluation mode, 'fetchGit' requires a Git revision");
 
-  if (!ref && rev == "" && hasPrefix(uri, "/") && pathExists(uri + "/.git")) {
+  if (!ref && rev == "" && absl::StartsWith(uri, "/") &&
+      pathExists(uri + "/.git")) {
     bool clean = true;
 
     try {
@@ -56,7 +58,7 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
           runProgram("git", true, {"-C", uri, "ls-files", "-z"}), "\0"s);
 
       PathFilter filter = [&](const Path& p) -> bool {
-        assert(hasPrefix(p, uri));
+        assert(absl::StartsWith(p, uri));
         std::string file(p, uri.size() + 1);
 
         auto st = lstat(p);
@@ -64,7 +66,7 @@ GitInfo exportGit(ref<Store> store, const std::string& uri,
         if (S_ISDIR(st.st_mode)) {
           auto prefix = file + "/";
           auto i = files.lower_bound(prefix);
-          return i != files.end() && hasPrefix(*i, prefix);
+          return i != files.end() && absl::StartsWith(*i, prefix);
         }
 
         return files.count(file);
diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
index 69ece06eac..b6d4a5e1c8 100644
--- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc
+++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
@@ -2,6 +2,7 @@
 #include <regex>
 
 #include <absl/strings/ascii.h>
+#include <absl/strings/match.h>
 #include <glog/logging.h>
 #include <sys/time.h>
 
@@ -31,7 +32,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string& uri,
         "in pure evaluation mode, 'fetchMercurial' requires a Mercurial "
         "revision");
 
-  if (rev == "" && hasPrefix(uri, "/") && pathExists(uri + "/.hg")) {
+  if (rev == "" && absl::StartsWith(uri, "/") && pathExists(uri + "/.hg")) {
     bool clean = runProgram("hg", true,
                             {"status", "-R", uri, "--modified", "--added",
                              "--removed"}) == "";
@@ -54,7 +55,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string& uri,
           "\0"s);
 
       PathFilter filter = [&](const Path& p) -> bool {
-        assert(hasPrefix(p, uri));
+        assert(absl::StartsWith(p, uri));
         std::string file(p, uri.size() + 1);
 
         auto st = lstat(p);
@@ -62,7 +63,7 @@ HgInfo exportMercurial(ref<Store> store, const std::string& uri,
         if (S_ISDIR(st.st_mode)) {
           auto prefix = file + "/";
           auto i = files.lower_bound(prefix);
-          return i != files.end() && hasPrefix(*i, prefix);
+          return i != files.end() && absl::StartsWith(*i, prefix);
         }
 
         return files.count(file);