products.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:fg21sim 作者: liweitianux 项目源码 文件源码
def validate_absolute_path(self, root, absolute_path):
        """
        Validate and return the absolute path.

        Credit:
        https://github.com/tornadoweb/tornado/blob/master/tornado/web.py
        """
        root = os.path.abspath(root)
        if not root.endswith(os.path.sep):
            root += os.path.sep
        if not (absolute_path + os.path.sep).startswith(root):
            # Only files under the specified root can be accessed
            raise HTTPError(403, "%s is not in the root directory", self.path)
        if not os.path.exists(absolute_path):
            raise HTTPError(404)
        if not os.path.isfile(absolute_path):
            raise HTTPError(403, "%s is not a file", self.path)
        return absolute_path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号