From 1e0cf70d1d09bbb04fbdecaf73e35b2b6a8bb606 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Mon, 6 Apr 2015 22:51:18 +0300 Subject: [PATCH] use standard URL encoder --- .../meviz/htmlindexer/WebIndexer.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java index acc1a28..213cfad 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java @@ -3,8 +3,10 @@ package eu.svjatoslav.meviz.htmlindexer; import java.io.BufferedInputStream; import java.io.IOException; import java.io.ObjectInputStream; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLEncoder; import java.util.List; import eu.svjatoslav.commons.network.UrlParamEncoder; @@ -25,15 +27,27 @@ public class WebIndexer extends AbstractIndexer { this.jspPath = jspPath; } + @Override + public void compileHtml(final Layout layout, + final DirectoryMetadata directory) + throws UnsupportedEncodingException { + super.compileHtml(layout, directory); + } + @Override public String getDirectoryUrl(final AbstractFile directory, final IndexingContext context) { - return jspPath + context.getLocalUrl() + "/" - + UrlParamEncoder.encode(directory.fileName); + + try { + return jspPath + context.getLocalUrl() + "/" + + URLEncoder.encode(directory.fileName, "UTF-8"); + } catch (final UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } public String getHtml(String requestPath) throws MalformedURLException, - IOException, ClassNotFoundException { + IOException, ClassNotFoundException { if (requestPath == null) requestPath = ""; @@ -110,14 +124,14 @@ public class WebIndexer extends AbstractIndexer { // file path if (picture.getDimensions().equals(desiredDimension)) return context.getGlobalUrl() + context.getLocalUrl() + "/" - + picture.fileName; + + picture.fileName; final String thumbnailFileName = picture .getRelativeThumbnailFileName(desiredDimension); return context.getGlobalUrl() + context.getLocalUrl() + "/" - + Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); + + Constants.THUMBNAILS_DIRECTORY_NAME + "/" + + UrlParamEncoder.encode(thumbnailFileName); } } -- 2.20.1