首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Django:[电子邮件受保护]在管理中

Django:[电子邮件受保护]在管理中
EN

Stack Overflow用户
提问于 2012-09-01 04:40:01
回答 3查看 2K关注 0票数 16

我遇到了一个看似简单的问题,但我还没有找到调试它的方法。

在我们的生产网站上的管理中,当编辑具有ForeignKey to User的对象时,所有用户都显示为email protected。这使得管理员在这些方面无法使用!

我试着用谷歌搜索这个问题,但因为“电子邮件受保护”一词出现在许多邮件列表中的无关上下文中,所以我找不到解决方案。此外,我在Django代码库中搜索了“电子邮件保护”,但我没有找到它。

你知道该怎么做吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2012-09-01 05:04:32

我真的不知道答案,但每当我在谷歌上看到受电子邮件保护的时,如果我导航到链接,那么电子邮件就会出现,如果我检查它附近的元素,就会显示这段javascript:

代码语言:javascript
运行
复制
/* <![CDATA[ */
(function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.className;if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
/* ]]> */

这可能会对你有进一步的帮助。(检查您的元素,看看这是否也适用于您。)

如果您在代码中也看到了这一点,那么Thisthis可能会对您有所帮助。

编辑:它似乎是由Cloudflare's email obfuscation引起的。

票数 22
EN

Stack Overflow用户

发布于 2017-01-25 15:27:33

电子邮件混淆是一件好事,为公共网站,我想禁用它的管理员。因此,我编写了这个中间件来禁用管理中的电子邮件混淆。

代码语言:javascript
运行
复制
def _insert_email_off(html):
    origin = html
    try:
        pos1 = html.index('>', html.index('<body')) + 1
        html = html[:pos1] + '<!--email_off-->' + html[pos1:]
        pos2 = html.index('</body>')
        html = html[:pos2] +'<!--/email_off-->' + html[pos2:]
    except ValueError:
        return origin
    return html


class CloudflareEmailProtect(MiddlewareMixin):

    def process_response(self, request, response):
        if request.path.startswith('/admin/'):
            response.content = smart_bytes(_insert_email_off(smart_text(response.content)))
        return response


class TestCloudflareEmailProtect:

    def test_admin(self, rf):
        request = rf.get('/admin/aaa')
        html = '<html><body>content</body>'
        response = CloudflareEmailProtect().process_response(request, HttpResponse(html))
        assert b'<!--email_off--' in response.content

    def test_not_admin(self, rf):
        request = rf.get('/public')
        html = '<html><body>content</body>'
        response = CloudflareEmailProtect().process_response(request, HttpResponse(html))
        assert b'<!--email_off--' not in response.content


def test_insert_email_off():
    html = 'aa <body zzz>bb cc</body>dd'
    result = _insert_email_off(html)
    assert result == 'aa <body zzz><!--email_off-->bb cc<!--/email_off--></body>dd'

    assert _insert_email_off('aaa') == 'aaa'
票数 1
EN

Stack Overflow用户

发布于 2019-07-24 20:40:47

我也面临着这个问题,浪费了太多的时间来解决。最后,我解决了这个问题,只需添加简单的。

选项-1:

在HTML页面中添加

代码语言:javascript
运行
复制
<!--email_off-->YOUR_EMAIL_ADDRESS<!--/email_off-->

这个问题主要是关于"Cloudflare混淆电子邮件“的。

选项2:

从dashbaord停用。

  1. 登录到Cloudflare控制面板。

  1. 确保选择了要验证的网站。

  1. 单击刮除盾牌应用程序。

  1. 在电子邮件地址混淆下,检查切换是否设置为On。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12222196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档