update from master
authorNiki Roo <niki@nikiroo.be>
Thu, 28 May 2020 14:55:51 +0000 (16:55 +0200)
committerNiki Roo <niki@nikiroo.be>
Thu, 28 May 2020 14:55:51 +0000 (16:55 +0200)
library/WebLibraryServer.java
library/WebLibraryUrls.java

index 56d78ed4de20b5a52583af21105043a07cc8e89f..1fce3911eb67f5b47cb95198a9a8c542da9ebf2d 100644 (file)
@@ -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);
index 2b757798c5aec05c044e29b4971a7043a1f59baa..5d628e023d33e47b92542ff9c4273614864c7d33 100644 (file)
@@ -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;
+               }
+       }
 }