2012-08-31 4 views
16

겉으로보기에는 간단한 문제가 있지만 디버깅 할 방법을 찾지 못했습니다.Django : [전자 메일 보호] 관리자의

생산 웹 사이트의 관리자가 ForeignKey to User를 가진 개체를 편집 할 때 모든 사용자는 [전자 메일 보호]으로 표시됩니다. 따라서 관리자는이 영역에서 사용할 수 없게됩니다!

나는 문제를 찾기를 시도했으나 관련없는 컨텍스트에서 많은 메일 링리스트에 "이메일 보호됨"이라는 용어가 표시되어 해결책을 찾을 수 없습니다. 또한 장고 코드베이스에서 "보호 된 전자 메일"을 검색했지만 찾지 못했습니다.

무엇을해야할까요?

+0

설치된 django 모듈을보고도 거기에 있는지 확인 했습니까? 이 문제의 원인이되는 타사 모듈이 있다면 놀랄 일이 아닙니다. –

+0

방금 ​​현재 안정 릴리스 (1.4.1)를 확인했는데 코드베이스에서 아무것도 찾을 수 없습니다. Django의 어떤 버전이 제작 과정에서 실행되고 있습니까? –

+0

사용자의 __unicode__ 기능은 어떻게 생겼습니까? 그것은 사용자 mailadress를 반환합니까? – Jingo

답변

22

나는 대답을 정말로 모르지만 언제든지 [전자 메일 보호]이 Google에 나타나면 링크로 이동하면 전자 메일이 나옵니다. 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에 의한 것 같습니다.

+2

사실 CloudFlare였습니다. –

+2

이봐, 나는 이것을 조사하는 데 하루 종일 낭비했다. 내 의혹을 확인해 주셔서 감사합니다. – Vlad

+1

CloudFlare와 동일한 문제가 있습니다. https://www.cloudflare.com/cloudflare-settings?z=YOURDOMAIN.com#page=security로 이동하여 전자 메일 난독 화를 해제하십시오. –

1

전자 메일 난독 화는 공용 사이트에 좋으며 admin 용으로 비활성화하려고합니다. 그래서 나는이 미들웨어를 작성하여 관리자의 전자 메일 난독 화를 비활성화합니다.

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' 
+0

cloudflare 대시 보드에서 페이지 규칙을 통해 비활성화 할 수 있습니다. – if237912print

관련 문제