From: Niki Roo Date: Thu, 28 May 2020 14:55:51 +0000 (+0200) Subject: update from master X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=af6e65daddff2d602017013f498f989fefbb6be9;p=fanfix.git update from master --- diff --git a/library/WebLibraryServer.java b/library/WebLibraryServer.java index 56d78ed..1fce391 100644 --- a/library/WebLibraryServer.java +++ b/library/WebLibraryServer.java @@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -395,7 +396,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { } String type = uriParts[off + 0]; - String id = uriParts[off + 1]; + String id = URLDecoder.decode(uriParts[off + 1], "UTF-8"); InputStream in = null; @@ -446,7 +447,7 @@ public class WebLibraryServer extends WebLibraryServerHtml { } String type = uriParts[off + 0]; - String id = uriParts[off + 1]; + String id = URLDecoder.decode(uriParts[off + 1], "UTF-8"); if ("source".equals(type)) { sourceCover(id, login, luid); diff --git a/library/WebLibraryUrls.java b/library/WebLibraryUrls.java index 2b75779..5d628e0 100644 --- a/library/WebLibraryUrls.java +++ b/library/WebLibraryUrls.java @@ -1,5 +1,8 @@ package be.nikiroo.fanfix.library; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + class WebLibraryUrls { static public final String INDEX_URL = "/"; @@ -52,7 +55,7 @@ class WebLibraryUrls { + "author/{author}"; static private final String COVER_URL_SOURCE = COVER_URL_BASE + "source/{source}"; - + static public String getViewUrl(String luid, Integer chap, Integer para) { return VIEWER_URL // .replace("{luid}", luid) // @@ -122,12 +125,12 @@ class WebLibraryUrls { static public String getCoverUrlSource(String source) { return COVER_URL_SOURCE // - .replace("{source}", source); + .replace("{source}", url(source)); } static public String getCoverUrlAuthor(String author) { return COVER_URL_AUTHOR // - .replace("{author}", author); + .replace("{author}", url(author)); } static public String getDeleteUrlStory(String luid) { @@ -158,4 +161,14 @@ class WebLibraryUrls { static public boolean isDeleteUrl(String url) { return url != null && url.startsWith(DELETE_URL_BASE); } + + static private String url(String value) { + try { + return URLEncoder.encode(value, "UTF-8"); + } catch (UnsupportedEncodingException e) { + // UTF-8 is always supported + e.printStackTrace(); + return value; + } + } }