瀏覽代碼

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"))


Loading…
取消
儲存