isPathSafe function

bool isPathSafe(
  1. String destinationPath,
  2. String projectRoot
)

Implementation

bool isPathSafe(String destinationPath, String projectRoot) {
  if (path.isAbsolute(destinationPath)) {
    return false;
  }

  final normalizedDest =
      path.normalize(path.join(projectRoot, destinationPath));
  final normalizedRoot = path.normalize(projectRoot);
  return normalizedDest.startsWith(normalizedRoot);
}