From ef752083572bc249004a3c077077e0f366b1a6fd Mon Sep 17 00:00:00 2001 From: sponge Date: Fri, 14 Sep 2012 02:51:13 +0000 Subject: [PATCH] Presanitize, no need to resanitize. --- netdb.i2p2/fixedapp.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/netdb.i2p2/fixedapp.py b/netdb.i2p2/fixedapp.py index 95ae76f0..8bfcc233 100644 --- a/netdb.i2p2/fixedapp.py +++ b/netdb.i2p2/fixedapp.py @@ -134,10 +134,10 @@ def application(environ, start_response): if (len(stuff) == 0): # generate links entries = os.listdir(netdbdir) + new = [] if len(entries) > 150: # select some randomly - new = [] - for i in range(100): + for i in xrange(100): while True: sel = choice(entries) if not sel.startswith('routerInfo-'): @@ -146,7 +146,14 @@ def application(environ, start_response): new.append(sel) cur.execute("insert into entry values (?, ?)", (nowtag, sel)) break - entries = new + else: + for sel in entries: + if not sel.startswith('routerInfo-'): + continue + if sel not in new: + new.append(sel) + cur.execute("insert into entry values (?, ?)", (nowtag, sel)) + entries = new else: # Use what we already generated entries = [] @@ -165,8 +172,9 @@ def application(environ, start_response): res = '' for entry in entries: - if not entry.startswith('routerInfo-'): - continue + # Already sanitized above. + #if not entry.startswith('routerInfo-'): + # continue res += '
  • %s
  • ' % (entry, entry) resp = Response(page % res, mimetype='text/html') resp.add_etag()