Kaynağa Gözat

Ignore cookies set by other TS services.

pull/24/head
Ben Kurtovic 12 yıl önce
ebeveyn
işleme
e223412e79
2 değiştirilmiş dosya ile 6 ekleme ve 3 silme
  1. +2
    -2
      pages/settings.mako
  2. +4
    -1
      toolserver/cookies.py

+ 2
- 2
pages/settings.mako Dosyayı Görüntüle

@@ -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 Dosyayı Görüntüle

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


Yükleniyor…
İptal
Kaydet