From 0ebf4a7e60e64c6f1ebfdae0ffe169988a687468 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Nov 2011 11:53:51 +0100 Subject: [PATCH] Filter links from image and album descriptions. --- src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java | 3 ++- src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java | 3 ++- src/main/java/net/pterodactylus/sone/web/EditImagePage.java | 3 ++- src/main/java/net/pterodactylus/sone/web/UploadImagePage.java | 3 ++- src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java | 3 ++- src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java | 3 ++- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java index a695952..9072ea4 100644 --- a/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/CreateAlbumPage.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Sone; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -64,7 +65,7 @@ public class CreateAlbumPage extends SoneTemplatePage { String parentId = request.getHttpRequest().getPartAsStringFailsafe("parent", 36); Album parent = webInterface.getCore().getAlbum(parentId, false); Album album = webInterface.getCore().createAlbum(currentSone, parent); - album.setTitle(name).setDescription(description); + album.setTitle(name).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); webInterface.getCore().touchConfiguration(); throw new RedirectException("imageBrowser.html?album=" + album.getId()); } diff --git a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java index fd4bf7c..8f595a7 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditAlbumPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -68,7 +69,7 @@ public class EditAlbumPage extends SoneTemplatePage { return; } String description = request.getHttpRequest().getPartAsStringFailsafe("description", 1000).trim(); - album.setTitle(title).setDescription(description); + album.setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); webInterface.getCore().touchConfiguration(); throw new RedirectException("imageBrowser.html?album=" + album.getId()); } diff --git a/src/main/java/net/pterodactylus/sone/web/EditImagePage.java b/src/main/java/net/pterodactylus/sone/web/EditImagePage.java index 7e9eb7e..a0939db 100644 --- a/src/main/java/net/pterodactylus/sone/web/EditImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/EditImagePage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web; import net.pterodactylus.sone.data.Image; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; @@ -73,7 +74,7 @@ public class EditImagePage extends SoneTemplatePage { templateContext.set("titleMissing", true); } image.setTitle(title); - image.setDescription(description); + image.setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); } webInterface.getCore().touchConfiguration(); throw new RedirectException(returnPage); diff --git a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java index e0aa1e1..e160c32 100644 --- a/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java +++ b/src/main/java/net/pterodactylus/sone/web/UploadImagePage.java @@ -33,6 +33,7 @@ import javax.imageio.stream.ImageInputStream; import net.pterodactylus.sone.data.Album; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.data.TemporaryImage; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.io.StreamCopier; @@ -120,7 +121,7 @@ public class UploadImagePage extends SoneTemplatePage { String mimeType = getMimeType(imageData); TemporaryImage temporaryImage = webInterface.getCore().createTemporaryImage(mimeType, imageData); image = webInterface.getCore().createImage(currentSone, parent, temporaryImage); - image.setTitle(name).setDescription(description).setWidth(uploadedImage.getWidth(null)).setHeight(uploadedImage.getHeight(null)); + image.setTitle(name).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)).setWidth(uploadedImage.getWidth(null)).setHeight(uploadedImage.getHeight(null)); } catch (IOException ioe1) { logger.log(Level.WARNING, "Could not read uploaded image!", ioe1); return; diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java index 53f0466..8bc07ef 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditAlbumAjaxPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.data.Album; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; @@ -68,7 +69,7 @@ public class EditAlbumAjaxPage extends JsonPage { } String title = request.getHttpRequest().getParam("title").trim(); String description = request.getHttpRequest().getParam("description").trim(); - album.setTitle(title).setDescription(description); + album.setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); webInterface.getCore().touchConfiguration(); return createSuccessJsonObject().put("albumId", album.getId()).put("title", album.getTitle()).put("description", album.getDescription()); } diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java index 17d171b..3bef432 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/EditImageAjaxPage.java @@ -18,6 +18,7 @@ package net.pterodactylus.sone.web.ajax; import net.pterodactylus.sone.data.Image; +import net.pterodactylus.sone.text.TextFilter; import net.pterodactylus.sone.web.WebInterface; import net.pterodactylus.sone.web.page.FreenetRequest; import net.pterodactylus.util.json.JsonObject; @@ -68,7 +69,7 @@ public class EditImageAjaxPage extends JsonPage { } String title = request.getHttpRequest().getParam("title").trim(); String description = request.getHttpRequest().getParam("description").trim(); - image.setTitle(title).setDescription(description); + image.setTitle(title).setDescription(TextFilter.filter(request.getHttpRequest().getHeader("host"), description)); webInterface.getCore().touchConfiguration(); return createSuccessJsonObject().put("imageId", image.getId()).put("title", image.getTitle()).put("description", image.getDescription()); } -- 2.7.4