1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-04 23:10:11 +01:00

watermark stuff

This commit is contained in:
Anthony Stirling 2023-07-01 22:18:49 +01:00
parent c140052822
commit 5ea3bcc1dd
18 changed files with 65 additions and 46 deletions

View File

@ -1,4 +1,5 @@
package stirling.software.SPDF.config; package stirling.software.SPDF.config;
import java.util.List; import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; 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.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
public class CleanUrlInterceptor implements HandlerInterceptor { public class CleanUrlInterceptor implements HandlerInterceptor {
private static final List<String> ALLOWED_PARAMS = Arrays.asList("lang", "endpoint", "endpoints");
private static final List<String> 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 Map<String, String> parameters = new HashMap<>();
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<String, String> 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 // If there are any parameters that are not allowed
String[] queryParameters = queryString.split("&"); if (parameters.size() != queryParameters.length) {
for (String param : queryParameters) { // Construct new query string
String[] keyValue = param.split("="); StringBuilder newQueryString = new StringBuilder();
if (keyValue.length != 2) { for (Map.Entry<String, String> entry : parameters.entrySet()) {
continue; if (newQueryString.length() > 0) {
} newQueryString.append("&");
if (ALLOWED_PARAMS.contains(keyValue[0])) { }
parameters.put(keyValue[0], keyValue[1]); newQueryString.append(entry.getKey()).append("=").append(entry.getValue());
} }
}
// If there are any other query parameters besides the allowed ones // Redirect to the URL with only allowed query parameters
if (parameters.size() > 0) { String redirectUrl = requestURI + "?" + newQueryString;
// Construct new query string response.sendRedirect(redirectUrl);
StringBuilder newQueryString = new StringBuilder(); return false;
for (Map.Entry<String, String> entry : parameters.entrySet()) { }
if (newQueryString.length() > 0) { }
newQueryString.append("&"); return true;
} }
newQueryString.append(entry.getKey()).append("=").append(entry.getValue());
}
// Redirect to the URL with only allowed query parameters @Override
String redirectUrl = requestURI + "?" + newQueryString; public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
response.sendRedirect(redirectUrl); ModelAndView modelAndView) {
return false; }
}
}
return true;
}
@Override @Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler,
} Exception ex) {
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
}
} }

View File

@ -24,7 +24,7 @@ close=\u0625\u063A\u0644\u0627\u0642
filesSelected = الملفات المحددة filesSelected = الملفات المحددة
noFavourites = لم تتم إضافة أي مفضلات noFavourites = لم تتم إضافة أي مفضلات
bored = الانتظار بالملل؟ bored = الانتظار بالملل؟
alphabet=\u0627\u0644\u0623\u0628\u062C\u062F\u064A\u0629
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Tanca
filesSelected=fitxers seleccionats filesSelected=fitxers seleccionats
noFavourites=No s'ha afegit cap favorit noFavourites=No s'ha afegit cap favorit
bored=Avorrit esperant? bored=Avorrit esperant?
alphabet=Alfabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Schließen
filesSelected=Dateien ausgewählt filesSelected=Dateien ausgewählt
noFavourites=Keine Favoriten hinzugefügt noFavourites=Keine Favoriten hinzugefügt
bored=Gelangweiltes Warten? bored=Gelangweiltes Warten?
alphabet=Alphabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Close
filesSelected=files selected filesSelected=files selected
noFavourites=No favourites added noFavourites=No favourites added
bored=Bored Waiting? bored=Bored Waiting?
alphabet=Alphabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Cerrar
filesSelected=archivos seleccionados filesSelected=archivos seleccionados
noFavourites=No se agregaron favoritos noFavourites=No se agregaron favoritos
bored=¿Aburrido de esperar? bored=¿Aburrido de esperar?
alphabet=Alfabeto
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Itxi
filesSelected=Hautatutako fitxategiak filesSelected=Hautatutako fitxategiak
noFavourites=Ez dira gogokoak gehitu noFavourites=Ez dira gogokoak gehitu
bored=Itxaroten aspertuta? bored=Itxaroten aspertuta?
alphabet=Alfabetoa
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -24,6 +24,7 @@ close=Fermer
filesSelected=fichiers sélectionnés filesSelected=fichiers sélectionnés
noFavourites=Aucun favori ajouté noFavourites=Aucun favori ajouté
bored=Ennuyé d'attendre ? bored=Ennuyé d'attendre ?
alphabet=Alphabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Chiudi
filesSelected=file selezionati filesSelected=file selezionati
noFavourites=Nessun preferito noFavourites=Nessun preferito
bored=Stanco di aspettare? bored=Stanco di aspettare?
alphabet=Alfabeto
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -19,7 +19,8 @@ save=保存
close=閉じる close=閉じる
filesSelected=選択されたファイル filesSelected=選択されたファイル
noFavourites=お気に入りはありません noFavourites=お気に入りはありません
bored=待ち時間が退屈? bored=å¾…ã<EFBFBD>¡æ™é“ã<EFBFBD>Œé€€å±ˆï¼
alphabet=\u30A2\u30EB\u30D5\u30A1\u30D9\u30C3\u30C8Ÿ
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=닫기
filesSelected=개 파일 선택됨 filesSelected=개 파일 선택됨
noFavourites=즐겨찾기 없음 noFavourites=즐겨찾기 없음
bored=기다리는 게 지루하신가요? bored=기다리는 게 지루하신가요?
alphabet=\uC54C\uD30C\uBCB3
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Zamknij
filesSelected=wybrane pliki filesSelected=wybrane pliki
noFavourites=Nie dodano ulubionych noFavourites=Nie dodano ulubionych
bored=Znudzony czekaniem? bored=Znudzony czekaniem?
alphabet=Alfabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Fechar
filesSelected=arquivos selecionados filesSelected=arquivos selecionados
noFavourites=Nenhum favorito adicionado noFavourites=Nenhum favorito adicionado
bored=Entediado esperando? bored=Entediado esperando?
alphabet=Alfabeto
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Închide
filesSelected=fișiere selectate filesSelected=fișiere selectate
noFavourites=Niciun favorit adăugat noFavourites=Niciun favorit adăugat
bored=Plictisit așteptând? bored=Plictisit așteptând?
alphabet=Alfabet
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Закрыть
filesSelected=файлов выбрано filesSelected=файлов выбрано
noFavourites=Нет избранного noFavourites=Нет избранного
bored=Скучно ждать? bored=Скучно ждать?
alphabet=\u0430\u043B\u0444\u0430\u0432\u0438\u0442
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,6 +20,7 @@ close=Stäng
filesSelected=filer valda filesSelected=filer valda
noFavourites=Inga favoriter har lagts till noFavourites=Inga favoriter har lagts till
bored=Utråkad att vänta? bored=Utråkad att vänta?
alphabet=Alfabet
############# #############
# HEMSIDA # # HEMSIDA #
############# #############

View File

@ -20,6 +20,7 @@ close=关闭
filesSelected=\u9009\u62E9\u7684\u6587\u4EF6 filesSelected=\u9009\u62E9\u7684\u6587\u4EF6
noFavourites=\u6CA1\u6709\u6DFB\u52A0\u6536\u85CF\u5939 noFavourites=\u6CA1\u6709\u6DFB\u52A0\u6536\u85CF\u5939
bored=\u65E0\u804A\u7B49\u5F85\uFF1F bored=\u65E0\u804A\u7B49\u5F85\uFF1F
alphabet=\u5B57\u6BCD\u8868
############# #############
# HOME-PAGE # # HOME-PAGE #
############# #############

View File

@ -20,7 +20,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="fontSize" th:text="#{alphabet}"></label> <label for="fontSize" th:text="#{alphabet} + ':'"></label>
<select class="form-control" name="alphabet" id="alphabet-select"> <select class="form-control" name="alphabet" id="alphabet-select">
<option value="romain">Roman</option> <option value="romain">Roman</option>
<option value="arabic">العربية</option> <option value="arabic">العربية</option>