MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _pinned_python

Function _pinned_python

graphify/hooks.py:932–953  ·  view source on GitHub ↗

Return sys.executable if its path is shell-safe, else an empty string. Applies the same allowlist used in _PYTHON_DETECT: rejects any character that is not a valid plain filesystem path character, preventing $(...), backtick, double-quote, semicolon, etc. from being injected into genera

()

Source from the content-addressed store, hash-verified

930
931
932def _pinned_python() -> str:
933 """Return sys.executable if its path is shell-safe, else an empty string.
934
935 Applies the same allowlist used in _PYTHON_DETECT: rejects any character
936 that is not a valid plain filesystem path character, preventing $(...),
937 backtick, double-quote, semicolon, etc. from being injected into generated
938 shell scripts or the merge-driver command line. The allowlist includes ':'
939 and '\\' so Windows paths (C:\\...) are accepted, and a plain space so
940 Windows profile paths (C:\\Users\\First Last\\...) are too — a space cannot
941 start a substitution or a new command, and every consumer quotes the value:
942 the hook scripts embed it as '$_PINNED' (single-quoted, then referenced as
943 "$_PINNED") and _register_merge_driver double-quotes it (#2166). Before that
944 a space rejected the whole path, so hooks installed under any Windows user
945 whose profile name contains a space silently pinned nothing. An empty return
946 means callers must fall back to the `graphify` launcher on PATH — safe
947 degradation.
948 """
949 if re.search(r"[^a-zA-Z0-9/_.@: \\-]", sys.executable):
950 return ""
951 if _is_rotating_prefix(sys.executable):
952 return ""
953 return sys.executable
954
955
956# ``~/snap/<app>/<revision>/`` — snap swaps <revision> on every package update and

Calls 1

_is_rotating_prefixFunction · 0.85