From 49f646dc72f59ebd385915ba8362902459557b7f Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 6 Oct 2011 22:15:57 +0200 Subject: [PATCH] Add default implementations that do not allow linking. --- src/main/java/net/pterodactylus/sone/web/GetImagePage.java | 13 +++++++++++-- .../java/net/pterodactylus/sone/web/ajax/JsonPage.java | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/GetImagePage.java b/src/main/java/net/pterodactylus/sone/web/GetImagePage.java index 29556c9..8f0c474 100644 --- a/src/main/java/net/pterodactylus/sone/web/GetImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/GetImagePage.java @@ -18,10 +18,11 @@ package net.pterodactylus.sone.web; import java.io.IOException; +import java.net.URI; import net.pterodactylus.sone.data.TemporaryImage; +import net.pterodactylus.sone.web.page.FreenetPage; import net.pterodactylus.sone.web.page.FreenetRequest; -import net.pterodactylus.util.web.Page; import net.pterodactylus.util.web.Response; /** @@ -29,7 +30,7 @@ import net.pterodactylus.util.web.Response; * * @author David ‘Bombe’ Roden */ -public class GetImagePage implements Page { +public class GetImagePage implements FreenetPage { /** The Sone web interface. */ private final WebInterface webInterface; @@ -74,4 +75,12 @@ public class GetImagePage implements Page { return response.setStatusCode(200).setStatusText("OK").setContentType(contentType).addHeader("Content-Disposition", "attachment; filename=" + temporaryImage.getId() + "." + contentType.substring(contentType.lastIndexOf('/') + 1)).write(temporaryImage.getImageData()); } + /** + * {@inheritDoc} + */ + @Override + public boolean isLinkExcepted(URI link) { + return false; + } + } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java index 1e5e8ed..4ee3b99 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/JsonPage.java @@ -18,16 +18,18 @@ package net.pterodactylus.sone.web.ajax; import java.io.IOException; +import java.net.URI; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.web.WebInterface; +import net.pterodactylus.sone.web.page.FreenetPage; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; import net.pterodactylus.util.json.JsonUtils; import net.pterodactylus.util.web.Page; import net.pterodactylus.util.web.Response; -import freenet.clients.http.SessionManager.Session; import freenet.clients.http.ToadletContext; +import freenet.clients.http.SessionManager.Session; /** * A JSON page is a specialized {@link Page} that will always return a JSON @@ -35,7 +37,7 @@ import freenet.clients.http.ToadletContext; * * @author David ‘Bombe’ Roden */ -public abstract class JsonPage implements Page { +public abstract class JsonPage implements FreenetPage { /** The path of the page. */ private final String path; @@ -218,4 +220,12 @@ public abstract class JsonPage implements Page { return response.setStatusCode(200).setStatusText("OK").setContentType("application/json").write(JsonUtils.format(jsonObject)); } + /** + * {@inheritDoc} + */ + @Override + public boolean isLinkExcepted(URI link) { + return false; + } + } -- 2.7.4