AuthMatrix.py 文件源码

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

项目:AuthMatrix 作者: SecurityInnovation 项目源码 文件源码
def chainReplace(toRegex, toValue, toArray):
        # TODO clean up so that the input is headers+body and its called only once
        # TODO support encoding, including URL encode
        isBody = len(toArray)==1
        if toRegex:
            # BUG FIX: Geoff reported that if the regex ends at the newline on the last header,
            # the regex fails.  Hacky solution is to add an extra newlines before the regex search
            # and remove it after.
            to = "\r\n".join(toArray)+"\r\n\r\n"
            match = re.search(toRegex, to, re.DOTALL)
            if match and len(match.groups()):
                ret = (to[0:match.start(1)]+toValue+to[match.end(1):])
                if ret[-4:] == "\r\n\r\n":
                    ret = ret[:-4]
                if isBody:
                    return [ret]
                else:
                    return ret.split("\r\n")
        return toArray

    ## Method to replace custom special types in messages
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号