%\=F d dl Z d dlZd dlmZ d dlZ ej d ZdZdedefdZde de fd Z
de defd
Zde fdZ
defd
ZdefdZd Zd ZdS ) N)Pathz([0-9]+)\.([0-9]+)\.([0-9]+)z \/:*?"<>|pathreturnc t | t j S # t $ r | cY S w xY w)zv
Returns the path relative to the current working directory if possible. Otherwise return the path unchanged.
)relative_toosgetcwd
ValueError)r s h/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pytest_snapshot/_utils.pyshorten_pathr sE ,,, s %( 77sc t | dd } t j dd| } dddd | | } | S ) z
Return the given string converted to a string that can be used for a clean filename.
Taken from https://github.com/django/django/blob/master/django/utils/text.py
_z(?u)[^-\w.] emptydotdotdot)r ...)strstripreplaceresubgetr
s r get_valid_filenamer s^
AsC((A
~r1%%A
51155a;;AH c t dk p+ dk p% dk pt fdt D S )a
Returns false if the given string is definitely a path traversal or not a valid filename.
Returns true if the string might be a valid filename.
Note: This isn't secure, it just catches most accidental path traversals or invalid filenames.
r r r c 3 K | ]}|v V d S N ).0cr
s r