소스 검색

Ignore cookies set by other TS services.

pull/24/head
Ben Kurtovic 12 년 전
부모
커밋
e223412e79
2개의 변경된 파일6개의 추가작업 그리고 3개의 파일을 삭제
  1. +2
    -2
      pages/settings.mako
  2. +4
    -1
      toolserver/cookies.py

+ 2
- 2
pages/settings.mako 파일 보기

@@ -23,7 +23,7 @@
</select>
<tt>.</tt>
<select name="project">
<% selected_project = cookies["EarwigDefaultProject"].value if "EarwigDefaultProject" in cookies else bot.wiki.get_site().lang %>
<% selected_project = cookies["EarwigDefaultProject"].value if "EarwigDefaultProject" in cookies else bot.wiki.get_site().project %>
% for code, name in projects:
% if code == selected_project:
<option value="${code}" selected="selected">${name}</option>
@@ -48,7 +48,7 @@
<ul>
% for cookie in cookies.itervalues():
<li>
<tt>${cookie.key | h}</tt>: <tt>${cookie.value | h}</tt> (<tt>${cookie["path"] | h}</tt>)
<tt>${cookie.key | h}</tt>: <tt>${cookie.value | h}</tt>
<form action="${environ['PATH_INFO']}" method="post">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="cookie" value="${cookie.key | h}">


+ 4
- 1
toolserver/cookies.py 파일 보기

@@ -12,13 +12,16 @@ class _CookieManager(SimpleCookie):
super(_CookieManager, self).__init__(environ["HTTP_COOKIE"])
except (CookieError, AttributeError):
super(_CookieManager, self).__init__()
for cookie in self:
if self[cookie].value is False:
del self[cookie]

def value_decode(self, value):
unquoted = super(_CookieManager, self).value_decode(value)[0]
try:
return base64.b64decode(unquoted).decode("utf8"), value
except (TypeError, UnicodeDecodeError):
return u"False", "False"
return False, "False"

def value_encode(self, value):
encoded = base64.b64encode(value.encode("utf8"))


불러오는 중...
취소
저장