Avoids env var warning when path contains $/%; fix #832 by rgkimball · Pull Request #961 · gitpython-developers/GitPython (original) (raw)
I ran into the same issue as @kamadoatfluid in #832, as I have a mounted disk path including a $
(valid file & folder character in most operating systems, as is %
). Since this is intended to catch environment variables per #662, I propose the use of regex instead to prevent irrelevant warnings from cluttering logs/console output.
This PR supports all expansion conventions demonstrated in os.path.expandvars, and also aligns with environment variable naming specifications. Illegal variables simply will cause errors and therefore don't present a security risk: word characters only, beginning with a-z
or _
.
Supported formats:
% APPDATA %
or%APPDATA%
$MYVAR
${MYVAR}