forked from I2P_Developers/i2p.i2p
escape semicolons
This commit is contained in:
@@ -900,13 +900,14 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write(trackerLink);
|
out.write(trackerLink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String encodedBaseName = urlEncode(snark.getBaseName());
|
||||||
// File type icon column
|
// File type icon column
|
||||||
out.write("</td>\n<td class=\"" + rowClass + "\">");
|
out.write("</td>\n<td class=\"" + rowClass + "\">");
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
// Link to local details page - note that trailing slash on a single-file torrent
|
// Link to local details page - note that trailing slash on a single-file torrent
|
||||||
// gets us to the details page instead of the file.
|
// gets us to the details page instead of the file.
|
||||||
StringBuilder buf = new StringBuilder(128);
|
StringBuilder buf = new StringBuilder(128);
|
||||||
buf.append("<a href=\"").append(snark.getBaseName())
|
buf.append("<a href=\"").append(encodedBaseName)
|
||||||
.append("/\" title=\"").append(_("Torrent details"))
|
.append("/\" title=\"").append(_("Torrent details"))
|
||||||
.append("\">");
|
.append("\">");
|
||||||
out.write(buf.toString());
|
out.write(buf.toString());
|
||||||
@@ -929,7 +930,7 @@ public class I2PSnarkServlet extends Default {
|
|||||||
out.write("</td><td class=\"snarkTorrentName " + rowClass + "\">");
|
out.write("</td><td class=\"snarkTorrentName " + rowClass + "\">");
|
||||||
if (remaining == 0 || isMultiFile) {
|
if (remaining == 0 || isMultiFile) {
|
||||||
StringBuilder buf = new StringBuilder(128);
|
StringBuilder buf = new StringBuilder(128);
|
||||||
buf.append("<a href=\"").append(snark.getBaseName());
|
buf.append("<a href=\"").append(encodedBaseName);
|
||||||
if (isMultiFile)
|
if (isMultiFile)
|
||||||
buf.append('/');
|
buf.append('/');
|
||||||
buf.append("\" title=\"");
|
buf.append("\" title=\"");
|
||||||
@@ -1623,10 +1624,15 @@ public class I2PSnarkServlet extends Default {
|
|||||||
private static String urlify(String s) {
|
private static String urlify(String s) {
|
||||||
StringBuilder buf = new StringBuilder(256);
|
StringBuilder buf = new StringBuilder(256);
|
||||||
// browsers seem to work without doing this but let's be strict
|
// browsers seem to work without doing this but let's be strict
|
||||||
String link = s.replace("&", "&").replace(" ", "%20");
|
String link = urlEncode(s);
|
||||||
buf.append("<a href=\"").append(link).append("\">").append(link).append("</a>");
|
buf.append("<a href=\"").append(link).append("\">").append(link).append("</a>");
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @since 0.8.13 */
|
||||||
|
private static String urlEncode(String s) {
|
||||||
|
return s.replace("&", "&").replace(" ", "%20").replace(":", "%3A").replace("/", "%2F").replace(";", "%3B");
|
||||||
|
}
|
||||||
|
|
||||||
private static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
|
private static final String DOCTYPE = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
|
||||||
private static final String HEADER_A = "<link href=\"";
|
private static final String HEADER_A = "<link href=\"";
|
||||||
@@ -1761,6 +1767,12 @@ public class I2PSnarkServlet extends Default {
|
|||||||
// .append(MAGGOT).append(hex).append(':').append(hex).append("</a>");
|
// .append(MAGGOT).append(hex).append(':').append(hex).append("</a>");
|
||||||
buf.append("<br>").append(_("Torrent file")).append(": ").append(snark.getName());
|
buf.append("<br>").append(_("Torrent file")).append(": ").append(snark.getName());
|
||||||
buf.append("</div></th></tr>");
|
buf.append("</div></th></tr>");
|
||||||
|
} else {
|
||||||
|
// shouldn't happen
|
||||||
|
buf.append("<tr><th>Not found<br>resource=\"").append(r.toString())
|
||||||
|
.append("\"<br>base=\"").append(base)
|
||||||
|
.append("\"<br>torrent=\"").append(torrentName)
|
||||||
|
.append("\"</th></tr>");
|
||||||
}
|
}
|
||||||
if (ls == null) {
|
if (ls == null) {
|
||||||
// We are only showing the torrent info section
|
// We are only showing the torrent info section
|
||||||
@@ -2068,7 +2080,7 @@ private static class FetchAndAdd implements Runnable {
|
|||||||
//if (peerParam != null)
|
//if (peerParam != null)
|
||||||
// buf.append("<input type=\"hidden\" name=\"p\" value=\"").append(peerParam).append("\" >\n");
|
// buf.append("<input type=\"hidden\" name=\"p\" value=\"").append(peerParam).append("\" >\n");
|
||||||
buf.append(_("Torrent was not retrieved from {0}", urlify(_url)));
|
buf.append(_("Torrent was not retrieved from {0}", urlify(_url)));
|
||||||
String link = _url.replace("&", "&").replace(" ", "%20").replace(":", "%3A").replace("/", "%2F");
|
String link = urlEncode(_url);
|
||||||
/**** FIXME ticket #575
|
/**** FIXME ticket #575
|
||||||
buf.append(" - [<a href=\"/i2psnark/?newURL=").append(link).append("#add\" >");
|
buf.append(" - [<a href=\"/i2psnark/?newURL=").append(link).append("#add\" >");
|
||||||
buf.append(_("Retry"));
|
buf.append(_("Retry"));
|
||||||
|
Reference in New Issue
Block a user