o Ih+ @s8ddlZddlZddlmZdddZGdddZdS) N)SuspiciousFileOperationFcCsxtj|dvrtd||r,tt|dd}|s$d|j vr*td||S|tj|kr:td||S)N>...z$Could not derive file name from '%s'\/rz'Detected path traversal attempt in '%s'z%File name '%s' includes path elements) ospathbasenamerpathlib PurePosixPathstrreplace is_absoluteparts)nameallow_relative_pathr r9/usr/lib/python3/dist-packages/django/core/files/utils.pyvalidate_file_names  rc@seZdZdZeddZeddZeddZeddZeddZ eddZ ed dZ ed dZ ed dZ ed dZed dZeddZeddZeddZeddZddZddZddZddZdS)FileProxyMixinz A mixin class used to forward file methods to an underlaying file object. The internal file object has to be called "file":: class FileProxy(FileProxyMixin): def __init__(self, file): self.file = file cC|jjSN)fileencodingselfrrr$zFileProxyMixin.cCrr)rfilenorrrrr%rcCrr)rflushrrrrr&rcCrr)risattyrrrrr'rcCrr)rnewlinesrrrrr(rcCrr)rreadrrrrr)rcCrr)rreadintorrrrr*rcCrr)rreadlinerrrrr+rcCrr)r readlinesrrrrr,rcCrr)rseekrrrrr-rcCrr)rtellrrrrr.rcCrr)rtruncaterrrrr/rcCrr)rwriterrrrr0rcCrr)r writelinesrrrrr1rcCs|j p|jjSr)rclosedrrrrr,3szFileProxyMixin.closedcC$|jrdSt|jdr|jSdS)NFreadableT)r,hasattrrr.rrrrr.7   zFileProxyMixin.readablecCs2|jrdSt|jdr|jSdt|jddvS)NFwritablewmoder)r,r/rr1getattrrrrrr1>s   zFileProxyMixin.writablecCr-)NFseekableT)r,r/rr5rrrrr5Er0zFileProxyMixin.seekablecCs t|jSr)iterrrrrr__iter__Ls zFileProxyMixin.__iter__N)__name__ __module__ __qualname____doc__propertyrrr r!r"r#r$r%r&r'r(r)r*r+r,r.r1r5r7rrrrrs,               r)F)rr django.core.exceptionsrrrrrrrs