From 5ea3bcc1dd246d7e79d578081f82b3984cf5939a Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 1 Jul 2023 22:18:49 +0100 Subject: [PATCH] watermark stuff --- .../SPDF/config/CleanUrlInterceptor.java | 90 ++++++++++--------- src/main/resources/messages_ar_AR.properties | 2 +- src/main/resources/messages_ca_CA.properties | 1 + src/main/resources/messages_de_DE.properties | 1 + src/main/resources/messages_en_GB.properties | 1 + src/main/resources/messages_es_ES.properties | 1 + src/main/resources/messages_eu_ES.properties | 1 + src/main/resources/messages_fr_FR.properties | 1 + src/main/resources/messages_it_IT.properties | 1 + src/main/resources/messages_ja_JP.properties | 3 +- src/main/resources/messages_ko_KR.properties | 1 + src/main/resources/messages_pl_PL.properties | 1 + src/main/resources/messages_pt_BR.properties | 1 + src/main/resources/messages_ro_RO.properties | 1 + src/main/resources/messages_ru_RU.properties | 1 + src/main/resources/messages_sv_SE.properties | 1 + src/main/resources/messages_zh_CN.properties | 1 + .../templates/security/add-watermark.html | 2 +- 18 files changed, 65 insertions(+), 46 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java index 8262d14f..efa084b3 100644 --- a/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java +++ b/src/main/java/stirling/software/SPDF/config/CleanUrlInterceptor.java @@ -1,4 +1,5 @@ package stirling.software.SPDF.config; + import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -20,56 +21,59 @@ import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.ModelAndView; + public class CleanUrlInterceptor implements HandlerInterceptor { + private static final List ALLOWED_PARAMS = Arrays.asList("lang", "endpoint", "endpoints"); - private static final List ALLOWED_PARAMS = Arrays.asList("lang", "endpoint", "endpoints"); + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) + throws Exception { + String queryString = request.getQueryString(); + if (queryString != null && !queryString.isEmpty()) { + String requestURI = request.getRequestURI(); - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { - String queryString = request.getQueryString(); - if (queryString != null && !queryString.isEmpty()) { - String requestURI = request.getRequestURI(); + Map parameters = new HashMap<>(); - Map parameters = new HashMap<>(); + // Keep only the allowed parameters + String[] queryParameters = queryString.split("&"); + for (String param : queryParameters) { + String[] keyValue = param.split("="); + if (keyValue.length != 2) { + continue; + } + if (ALLOWED_PARAMS.contains(keyValue[0])) { + parameters.put(keyValue[0], keyValue[1]); + } + } - // Keep only the allowed parameters - String[] queryParameters = queryString.split("&"); - for (String param : queryParameters) { - String[] keyValue = param.split("="); - if (keyValue.length != 2) { - continue; - } - if (ALLOWED_PARAMS.contains(keyValue[0])) { - parameters.put(keyValue[0], keyValue[1]); - } - } + // If there are any parameters that are not allowed + if (parameters.size() != queryParameters.length) { + // Construct new query string + StringBuilder newQueryString = new StringBuilder(); + for (Map.Entry entry : parameters.entrySet()) { + if (newQueryString.length() > 0) { + newQueryString.append("&"); + } + newQueryString.append(entry.getKey()).append("=").append(entry.getValue()); + } - // If there are any other query parameters besides the allowed ones - if (parameters.size() > 0) { - // Construct new query string - StringBuilder newQueryString = new StringBuilder(); - for (Map.Entry entry : parameters.entrySet()) { - if (newQueryString.length() > 0) { - newQueryString.append("&"); - } - newQueryString.append(entry.getKey()).append("=").append(entry.getValue()); - } + // Redirect to the URL with only allowed query parameters + String redirectUrl = requestURI + "?" + newQueryString; + response.sendRedirect(redirectUrl); + return false; + } + } + return true; + } - // Redirect to the URL with only allowed query parameters - String redirectUrl = requestURI + "?" + newQueryString; - response.sendRedirect(redirectUrl); - return false; - } - } - return true; - } + @Override + public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) { + } - @Override - public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { - } - - @Override - public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - } + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, + Exception ex) { + } } diff --git a/src/main/resources/messages_ar_AR.properties b/src/main/resources/messages_ar_AR.properties index 1b52ba8a..f3991b4d 100644 --- a/src/main/resources/messages_ar_AR.properties +++ b/src/main/resources/messages_ar_AR.properties @@ -24,7 +24,7 @@ close=\u0625\u063A\u0644\u0627\u0642 filesSelected = الملفات المحددة noFavourites = لم تتم إضافة أي مفضلات bored = الانتظار بالملل؟ - +alphabet=\u0627\u0644\u0623\u0628\u062C\u062F\u064A\u0629 ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_ca_CA.properties b/src/main/resources/messages_ca_CA.properties index 0d785b2a..39d28ac5 100644 --- a/src/main/resources/messages_ca_CA.properties +++ b/src/main/resources/messages_ca_CA.properties @@ -20,6 +20,7 @@ close=Tanca filesSelected=fitxers seleccionats noFavourites=No s'ha afegit cap favorit bored=Avorrit esperant? +alphabet=Alfabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_de_DE.properties b/src/main/resources/messages_de_DE.properties index 47872c91..278f021b 100644 --- a/src/main/resources/messages_de_DE.properties +++ b/src/main/resources/messages_de_DE.properties @@ -20,6 +20,7 @@ close=Schließen filesSelected=Dateien ausgewählt noFavourites=Keine Favoriten hinzugefügt bored=Gelangweiltes Warten? +alphabet=Alphabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_en_GB.properties b/src/main/resources/messages_en_GB.properties index 391693f6..c4d3dc2f 100644 --- a/src/main/resources/messages_en_GB.properties +++ b/src/main/resources/messages_en_GB.properties @@ -20,6 +20,7 @@ close=Close filesSelected=files selected noFavourites=No favourites added bored=Bored Waiting? +alphabet=Alphabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_es_ES.properties b/src/main/resources/messages_es_ES.properties index a5958a67..43bb4c06 100644 --- a/src/main/resources/messages_es_ES.properties +++ b/src/main/resources/messages_es_ES.properties @@ -20,6 +20,7 @@ close=Cerrar filesSelected=archivos seleccionados noFavourites=No se agregaron favoritos bored=¿Aburrido de esperar? +alphabet=Alfabeto ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_eu_ES.properties b/src/main/resources/messages_eu_ES.properties index 320e9c99..58d969a7 100644 --- a/src/main/resources/messages_eu_ES.properties +++ b/src/main/resources/messages_eu_ES.properties @@ -20,6 +20,7 @@ close=Itxi filesSelected=Hautatutako fitxategiak noFavourites=Ez dira gogokoak gehitu bored=Itxaroten aspertuta? +alphabet=Alfabetoa ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_fr_FR.properties b/src/main/resources/messages_fr_FR.properties index fdc3a81a..07905cfa 100644 --- a/src/main/resources/messages_fr_FR.properties +++ b/src/main/resources/messages_fr_FR.properties @@ -24,6 +24,7 @@ close=Fermer filesSelected=fichiers sélectionnés noFavourites=Aucun favori ajouté bored=Ennuyé d'attendre ? +alphabet=Alphabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_it_IT.properties b/src/main/resources/messages_it_IT.properties index 7512a29b..cd6a5aa2 100644 --- a/src/main/resources/messages_it_IT.properties +++ b/src/main/resources/messages_it_IT.properties @@ -20,6 +20,7 @@ close=Chiudi filesSelected=file selezionati noFavourites=Nessun preferito bored=Stanco di aspettare? +alphabet=Alfabeto ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_ja_JP.properties b/src/main/resources/messages_ja_JP.properties index b0c96529..5aecb639 100644 --- a/src/main/resources/messages_ja_JP.properties +++ b/src/main/resources/messages_ja_JP.properties @@ -19,7 +19,8 @@ save=保存 close=閉じる filesSelected=選択されたファイル noFavourites=お気に入りはありません -bored=待ち時間が退屈? +bored=待ち時間が退屈 +alphabet=\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8 ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_ko_KR.properties b/src/main/resources/messages_ko_KR.properties index b978ab2d..fde2e5b3 100644 --- a/src/main/resources/messages_ko_KR.properties +++ b/src/main/resources/messages_ko_KR.properties @@ -20,6 +20,7 @@ close=닫기 filesSelected=개 파일 선택됨 noFavourites=즐겨찾기 없음 bored=기다리는 게 지루하신가요? +alphabet=\uC54C\uD30C\uBCB3 ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_pl_PL.properties b/src/main/resources/messages_pl_PL.properties index 19244f53..8e7434ce 100644 --- a/src/main/resources/messages_pl_PL.properties +++ b/src/main/resources/messages_pl_PL.properties @@ -20,6 +20,7 @@ close=Zamknij filesSelected=wybrane pliki noFavourites=Nie dodano ulubionych bored=Znudzony czekaniem? +alphabet=Alfabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_pt_BR.properties b/src/main/resources/messages_pt_BR.properties index c09b4ab3..842b93ce 100644 --- a/src/main/resources/messages_pt_BR.properties +++ b/src/main/resources/messages_pt_BR.properties @@ -20,6 +20,7 @@ close=Fechar filesSelected=arquivos selecionados noFavourites=Nenhum favorito adicionado bored=Entediado esperando? +alphabet=Alfabeto ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_ro_RO.properties b/src/main/resources/messages_ro_RO.properties index 3ea7829a..9a96fd11 100644 --- a/src/main/resources/messages_ro_RO.properties +++ b/src/main/resources/messages_ro_RO.properties @@ -20,6 +20,7 @@ close=Închide filesSelected=fișiere selectate noFavourites=Niciun favorit adăugat bored=Plictisit așteptând? +alphabet=Alfabet ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_ru_RU.properties b/src/main/resources/messages_ru_RU.properties index c7617c45..6f84ee5a 100644 --- a/src/main/resources/messages_ru_RU.properties +++ b/src/main/resources/messages_ru_RU.properties @@ -20,6 +20,7 @@ close=Закрыть filesSelected=файлов выбрано noFavourites=Нет избранного bored=Скучно ждать? +alphabet=\u0430\u043B\u0444\u0430\u0432\u0438\u0442 ############# # HOME-PAGE # ############# diff --git a/src/main/resources/messages_sv_SE.properties b/src/main/resources/messages_sv_SE.properties index 224fc41b..6608479d 100644 --- a/src/main/resources/messages_sv_SE.properties +++ b/src/main/resources/messages_sv_SE.properties @@ -20,6 +20,7 @@ close=Stäng filesSelected=filer valda noFavourites=Inga favoriter har lagts till bored=Utråkad att vänta? +alphabet=Alfabet ############# # HEMSIDA # ############# diff --git a/src/main/resources/messages_zh_CN.properties b/src/main/resources/messages_zh_CN.properties index 6ae7df00..0449ae93 100644 --- a/src/main/resources/messages_zh_CN.properties +++ b/src/main/resources/messages_zh_CN.properties @@ -20,6 +20,7 @@ close=关闭 filesSelected=\u9009\u62E9\u7684\u6587\u4EF6 noFavourites=\u6CA1\u6709\u6DFB\u52A0\u6536\u85CF\u5939 bored=\u65E0\u804A\u7B49\u5F85\uFF1F +alphabet=\u5B57\u6BCD\u8868 ############# # HOME-PAGE # ############# diff --git a/src/main/resources/templates/security/add-watermark.html b/src/main/resources/templates/security/add-watermark.html index b689b8e0..30091ea8 100644 --- a/src/main/resources/templates/security/add-watermark.html +++ b/src/main/resources/templates/security/add-watermark.html @@ -20,7 +20,7 @@
- +