A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: solve failing windows test with absolute path resolution (#9139)
Dylan Madisetti376932359dde
diff --git a/marimo/_server/files/path_validator.py b/marimo/_server/files/path_validator.pyindex f36b3ddf39..9beee0c9aa 100644--- a/marimo/_server/files/path_validator.py+++ b/marimo/_server/files/path_validator.py@@ -1,6 +1,7 @@# Copyright 2024 Marimo. All rights reserved.from __future__ import annotations+import osfrom pathlib import Pathfrom marimo import _loggers@@ -88,8 +89,6 @@ class PathValidator:Returns:Normalized absolute path without symlink resolution"""- import os-from marimo._utils.tmpdir import _convert_to_long_pathname# Make absolute relative to base if needed@@ -196,18 +195,35 @@ class PathValidator:))- # If it was an absolute directory, then the base is that directory- # otherwise, the base is the current working directory- if directory.is_absolute():- filepath_base = directory- else:- filepath_base = Path.cwd()+ filepath_base = (+ directory if directory.is_absolute() else Path.cwd()+ )+ # Original-form absolute directory (no long-path conversion).+ # filepath_base / directory is a no-op when directory is absolute.+ directory_original = Path(+ os.path.normpath(filepath_base / directory)+ )- filepath_normalized = (- self._normalize_path_without_resolving_symlinks(- filepath, filepath_base+ # filepath_base / filepath is a no-op when filepath is absolute.+ abs_filepath = Path(os.path.normpath(filepath_base / filepath))++ try:+ # Both paths are in the same (possibly short) form, so+ # relative_to is reliable. Reuse directory_normalized (which+ # already had short→long conversion applied) as the prefix+ # so we never call _convert_to_long_pathname on a path that+ # may not exist yet (e.g. a copy destination).+ relative = abs_filepath.relative_to(directory_original)+ filepath_normalized = directory_normalized / relative+ except ValueError:+ # filepath is not inside directory; normalize it+ # independently so _check_containment can produce a clear+ # error. The security check will reject it either way.+ filepath_normalized = (+ self._normalize_path_without_resolving_symlinks(+ filepath, filepath_base+ ))- )self._check_containment(directory_normalized,filepath_normalized,