From: Svjatoslav Agejenko Date: Mon, 6 Apr 2015 19:51:18 +0000 (+0300) Subject: use standard URL encoder X-Git-Tag: meviz-1.0~29 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=1e0cf70d1d09bbb04fbdecaf73e35b2b6a8bb606;p=meviz.git use standard URL encoder --- 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); } }