我遇到了一个看似简单的问题,但我还没有找到调试它的方法。
在我们的生产网站上的管理中,当编辑具有ForeignKey to User的对象时,所有用户都显示为email protected。这使得管理员在这些方面无法使用!
我试着用谷歌搜索这个问题,但因为“电子邮件受保护”一词出现在许多邮件列表中的无关上下文中,所以我找不到解决方案。此外,我在Django代码库中搜索了“电子邮件保护”,但我没有找到它。
你知道该怎么做吗?
发布于 2012-09-01 05:04:32
我真的不知道答案,但每当我在谷歌上看到受电子邮件保护的时,如果我导航到链接,那么电子邮件就会出现,如果我检查它附近的元素,就会显示这段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){}})();
/* ]]> */这可能会对你有进一步的帮助。(检查您的元素,看看这是否也适用于您。)
如果您在代码中也看到了这一点,那么This和this可能会对您有所帮助。
编辑:它似乎是由Cloudflare's email obfuscation引起的。
发布于 2017-01-25 15:27:33
电子邮件混淆是一件好事,为公共网站,我想禁用它的管理员。因此,我编写了这个中间件来禁用管理中的电子邮件混淆。
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'发布于 2019-07-24 20:40:47
我也面临着这个问题,浪费了太多的时间来解决。最后,我解决了这个问题,只需添加简单的。
选项-1:
在HTML页面中添加
<!--email_off-->YOUR_EMAIL_ADDRESS<!--/email_off-->这个问题主要是关于"Cloudflare混淆电子邮件“的。
选项2:
从dashbaord停用。
https://stackoverflow.com/questions/12222196
复制相似问题