当前位置: 首页>>代码示例>>Python>>正文


Python filepath.InsecurePath方法代码示例

本文整理汇总了Python中twisted.python.filepath.InsecurePath方法的典型用法代码示例。如果您正苦于以下问题:Python filepath.InsecurePath方法的具体用法?Python filepath.InsecurePath怎么用?Python filepath.InsecurePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.filepath的用法示例。


在下文中一共展示了filepath.InsecurePath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getChild

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def getChild(self, path, request):
        """
        If this L{File}'s path refers to a directory, return a L{File}
        referring to the file named C{path} in that directory.

        If C{path} is the empty string, return a L{DirectoryLister} instead.
        """
        self.restat(reraise=False)

        if not self.isdir():
            return self.childNotFound

        if path:
            try:
                fpath = self.child(path)
            except filepath.InsecurePath:
                return self.childNotFound
        else:
            fpath = self.childSearchPreauth(*self.indexNames)
            if fpath is None:
                return self.directoryListing()

        if not fpath.exists():
            fpath = fpath.siblingExtensionSearch(*self.ignoredExts)
            if fpath is None:
                return self.childNotFound

        if platformType == "win32":
            # don't want .RPY to be different than .rpy, since that would allow
            # source disclosure.
            processor = InsensitiveDict(self.processors).get(fpath.splitext()[1])
        else:
            processor = self.processors.get(fpath.splitext()[1])
        if processor:
            return resource.IResource(processor(fpath.path, self.registry))
        return self.createSimilarFile(fpath.path)


    # methods to allow subclasses to e.g. decrypt files on the fly: 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:41,代码来源:static.py

示例2: testPreauthChild

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testPreauthChild(self):
        fp = filepath.FilePath(b'.')
        fp.preauthChild(b'foo/bar')
        self.assertRaises(filepath.InsecurePath, fp.child, u'/mon\u20acy') 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:test_paths.py

示例3: testInsecureUNIX

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureUNIX(self):
        self.assertRaises(filepath.InsecurePath, self.path.child, b"..")
        self.assertRaises(filepath.InsecurePath, self.path.child, b"/etc")
        self.assertRaises(filepath.InsecurePath, self.path.child, b"../..") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:6,代码来源:test_paths.py

示例4: testInsecureWin32

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureWin32(self):
        self.assertRaises(filepath.InsecurePath, self.path.child, b"..\\..")
        self.assertRaises(filepath.InsecurePath, self.path.child, b"C:randomfile") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:test_paths.py

示例5: testInsecureWin32Whacky

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureWin32Whacky(self):
        """
        Windows has 'special' filenames like NUL and CON and COM1 and LPR
        and PRN and ... god knows what else.  They can be located anywhere in
        the filesystem.  For obvious reasons, we do not wish to normally permit
        access to these.
        """
        self.assertRaises(filepath.InsecurePath, self.path.child, b"CON")
        self.assertRaises(filepath.InsecurePath, self.path.child, b"C:CON")
        self.assertRaises(filepath.InsecurePath, self.path.child, r"C:\CON") 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_paths.py

示例6: test_descendantOnly

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def test_descendantOnly(self):
        """
        If C{".."} is in the sequence passed to L{FilePath.descendant},
        L{InsecurePath} is raised.
        """
        self.assertRaises(
            filepath.InsecurePath,
            self.path.descendant, [u'mon\u20acy', u'..']) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:10,代码来源:test_paths.py

示例7: statusForFailure

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def statusForFailure(failure, what=None):
    """
    @param failure: a L{Failure}.
    @param what: a decription of what was going on when the failure occurred.
        If what is not C{None}, emit a cooresponding message via L{log.err}.
    @return: a response code cooresponding to the given C{failure}.
    """
    def msg(err):
        if what is not None:
            log.debug("{err} while {what}", err=err, what=what)

    if failure.check(IOError, OSError):
        e = failure.value[0]
        if e == errno.EACCES or e == errno.EPERM:
            msg("Permission denied")
            return responsecode.FORBIDDEN
        elif e == errno.ENOSPC:
            msg("Out of storage space")
            return responsecode.INSUFFICIENT_STORAGE_SPACE
        elif e == errno.ENOENT:
            msg("Not found")
            return responsecode.NOT_FOUND
        else:
            failure.raiseException()
    elif failure.check(NotImplementedError):
        msg("Unimplemented error")
        return responsecode.NOT_IMPLEMENTED
    elif failure.check(InsecurePath):
        msg("Insecure path")
        return responsecode.FORBIDDEN
    elif failure.check(HTTPError):
        code = IResponse(failure.value.response).code
        msg("%d response" % (code,))
        return code
    else:
        failure.raiseException() 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:38,代码来源:http.py

示例8: locateChild

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def locateChild(self, req, segments):
        """
        See L{IResource}C{.locateChild}.
        """
        # If getChild() finds a child resource, return it
        try:
            child = self.getChild(segments[0])
            if child is not None:
                return (child, segments[1:])
        except InsecurePath:
            raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Invalid URL path"))

        # If we're not backed by a directory, we have no children.
        # But check for existance first; we might be a collection resource
        # that the request wants created.
        self.fp.restat(False)
        if self.fp.exists() and not self.fp.isdir():
            return (None, ())

        # OK, we need to return a child corresponding to the first segment
        path = segments[0]

        if path == "":
            # Request is for a directory (collection) resource
            return (self, ())

        return (self.createSimilarFile(self.fp.child(path).path), segments[1:]) 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:29,代码来源:static.py

示例9: testPreauthChild

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testPreauthChild(self):
        fp = filepath.FilePath('.')
        fp.preauthChild('foo/bar')
        self.assertRaises(filepath.InsecurePath, fp.child, '/foo') 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:6,代码来源:test_paths.py

示例10: testInsecureUNIX

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureUNIX(self):
        self.assertRaises(filepath.InsecurePath, self.path.child, "..")
        self.assertRaises(filepath.InsecurePath, self.path.child, "/etc")
        self.assertRaises(filepath.InsecurePath, self.path.child, "../..") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:6,代码来源:test_paths.py

示例11: testInsecureWin32

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureWin32(self):
        self.assertRaises(filepath.InsecurePath, self.path.child, r"..\..")
        self.assertRaises(filepath.InsecurePath, self.path.child, r"C:randomfile") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:test_paths.py

示例12: testInsecureWin32Whacky

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def testInsecureWin32Whacky(self):
        """Windows has 'special' filenames like NUL and CON and COM1 and LPR
        and PRN and ... god knows what else.  They can be located anywhere in
        the filesystem.  For obvious reasons, we do not wish to normally permit
        access to these.
        """
        self.assertRaises(filepath.InsecurePath, self.path.child, "CON")
        self.assertRaises(filepath.InsecurePath, self.path.child, "C:CON")
        self.assertRaises(filepath.InsecurePath, self.path.child, r"C:\CON") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:test_paths.py

示例13: do

# 需要导入模块: from twisted.python import filepath [as 别名]
# 或者: from twisted.python.filepath import InsecurePath [as 别名]
def do(self, player, line, topic):
        topic = topic.lower().strip()
        try:
            helpFile = self.helpContentPath.child(topic).open()
        except (OSError, IOError, filepath.InsecurePath):
            player.send("No help available on ", topic, ".", "\n")
        else:
            player.send(helpFile.read(), '\n') 
开发者ID:twisted,项目名称:imaginary,代码行数:10,代码来源:action.py


注:本文中的twisted.python.filepath.InsecurePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。