From 43f68136096c0c800e0ba1a2e0029e4d090a5a06 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 15 Dec 2009 01:47:24 +0000 Subject: [PATCH] snark start/stop fix, action cleanups --- .../org/klomp/snark/web/I2PSnarkServlet.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java index c3341229f..2fbf10462 100644 --- a/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java +++ b/apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java @@ -185,7 +185,7 @@ public class I2PSnarkServlet extends HttpServlet { out.write("\n" + " "); out.write(_("Totals")); - out.write(" {"); + out.write(" ("); out.write(_("{0} torrents", snarks.size())); out.write(", "); out.write(DataHelper.formatSize(stats[5]) + "B, "); @@ -216,7 +216,7 @@ public class I2PSnarkServlet extends HttpServlet { String action = req.getParameter("action"); if (action == null) { // noop - } else if (_("Add torrent").equals(action)) { + } else if ("Add".equals(action)) { String newFile = req.getParameter("newFile"); String newURL = req.getParameter("newURL"); // NOTE - newFile currently disabled in HTML form - see below @@ -260,7 +260,7 @@ public class I2PSnarkServlet extends HttpServlet { } else { // no file or URL specified } - } else if (_("Stop").equals(action)) { + } else if ("Stop".equals(action)) { String torrent = req.getParameter("torrent"); if (torrent != null) { byte infoHash[] = Base64.decode(torrent); @@ -275,7 +275,7 @@ public class I2PSnarkServlet extends HttpServlet { } } } - } else if (_("Start").equals(action)) { + } else if ("Start".equals(action)) { String torrent = req.getParameter("torrent"); if (torrent != null) { byte infoHash[] = Base64.decode(torrent); @@ -357,7 +357,7 @@ public class I2PSnarkServlet extends HttpServlet { } } } - } else if (_("Save configuration").equals(action)) { + } else if ("Save".equals(action)) { String dataDir = req.getParameter("dataDir"); boolean autoStart = req.getParameter("autoStart") != null; String seedPct = req.getParameter("seedPct"); @@ -371,7 +371,7 @@ public class I2PSnarkServlet extends HttpServlet { boolean useOpenTrackers = req.getParameter("useOpenTrackers") != null; String openTrackers = req.getParameter("openTrackers"); _manager.updateConfig(dataDir, autoStart, seedPct, eepHost, eepPort, i2cpHost, i2cpPort, i2cpOpts, upLimit, upBW, useOpenTrackers, openTrackers); - } else if (_("Create torrent").equals(action)) { + } else if ("Create".equals(action)) { String baseData = req.getParameter("baseFile"); if (baseData != null && baseData.trim().length() > 0) { File baseFile = new File(_manager.getDataDir(), baseData); @@ -738,6 +738,7 @@ public class I2PSnarkServlet extends HttpServlet { // *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file out.write("
\n"); out.write("\n"); + out.write("\n"); out.write("
"); out.write(_("Add Torrent")); out.write("
\n
"); @@ -747,7 +748,7 @@ public class I2PSnarkServlet extends HttpServlet { //out.write("From file:
\n"); out.write("
 
\n"); + out.write("\" name=\"foo\" >
\n"); out.write("
 "); out.write(_("Alternately, you can copy .torrent files to the directory {0}.", _manager.getDataDir().getAbsolutePath())); out.write("\n"); @@ -766,6 +767,7 @@ public class I2PSnarkServlet extends HttpServlet { // *not* enctype="multipart/form-data", so that the input type=file sends the filename, not the file out.write("\n"); out.write("\n"); + out.write("\n"); out.write(""); out.write(_("Create Torrent")); out.write("
\n
"); @@ -798,7 +800,7 @@ public class I2PSnarkServlet extends HttpServlet { out.write("\" > "); out.write("
 
\n"); + out.write("\" name=\"foo\" >
\n"); out.write("\n
"); } @@ -813,6 +815,7 @@ public class I2PSnarkServlet extends HttpServlet { out.write("
\n"); out.write("
\n"); out.write("\n"); + out.write("\n"); out.write(""); out.write(_("Configuration")); out.write("
\n"); @@ -912,7 +915,7 @@ public class I2PSnarkServlet extends HttpServlet { out.write(" \n"); + out.write("\" name=\"foo\" >\n"); out.write("
\n"); out.write("
"); } @@ -970,6 +973,7 @@ private static class FetchAndAdd implements Runnable { in = new FileInputStream(file); MetaInfo info = new MetaInfo(in); String name = info.getName(); + name = DataHelper.stripHTML(name); // XSS name = name.replace('/', '_'); name = name.replace('\\', '_'); name = name.replace('&', '+');