aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-05-18 16:16:10 -0700
committerAnton Tananaev <anton@traccar.org>2023-05-18 16:16:10 -0700
commit39b293b9f66c3c539e180fb2bcf37849335100dc (patch)
tree13fe1758bc7c5b769dcb76bc1d944b0ad9cb0b49 /src/main/java
parent1e1e55537a6fcb2d5365ea2cbcb9c182d986e83a (diff)
downloadtrackermap-server-39b293b9f66c3c539e180fb2bcf37849335100dc.tar.gz
trackermap-server-39b293b9f66c3c539e180fb2bcf37849335100dc.tar.bz2
trackermap-server-39b293b9f66c3c539e180fb2bcf37849335100dc.zip
Fix override filter
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/web/OverrideFilter.java40
-rw-r--r--src/main/java/org/traccar/web/ResponseWrapper.java3
2 files changed, 23 insertions, 20 deletions
diff --git a/src/main/java/org/traccar/web/OverrideFilter.java b/src/main/java/org/traccar/web/OverrideFilter.java
index e6e02514c..70eb80a67 100644
--- a/src/main/java/org/traccar/web/OverrideFilter.java
+++ b/src/main/java/org/traccar/web/OverrideFilter.java
@@ -50,30 +50,32 @@ public class OverrideFilter implements Filter {
chain.doFilter(request, wrappedResponse);
byte[] bytes = wrappedResponse.getCapture();
- if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html")
- || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.json")) {
+ if (bytes != null) {
+ if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html")
+ || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.json")) {
- Server server;
- try {
- server = permissionsServiceProvider.get().getServer();
- } catch (StorageException e) {
- throw new RuntimeException(e);
- }
+ Server server;
+ try {
+ server = permissionsServiceProvider.get().getServer();
+ } catch (StorageException e) {
+ throw new RuntimeException(e);
+ }
- String title = server.getString("title", "Traccar");
- String description = server.getString("description", "Traccar GPS Tracking System");
- String colorPrimary = server.getString("colorPrimary", "#1a237e");
+ String title = server.getString("title", "Traccar");
+ String description = server.getString("description", "Traccar GPS Tracking System");
+ String colorPrimary = server.getString("colorPrimary", "#1a237e");
- String alteredContent = new String(wrappedResponse.getCapture())
- .replace("${title}", title)
- .replace("${description}", description)
- .replace("${colorPrimary}", colorPrimary);
+ String alteredContent = new String(wrappedResponse.getCapture())
+ .replace("${title}", title)
+ .replace("${description}", description)
+ .replace("${colorPrimary}", colorPrimary);
- response.setContentLength(alteredContent.length());
- response.getOutputStream().write(alteredContent.getBytes());
+ response.setContentLength(alteredContent.length());
+ response.getOutputStream().write(alteredContent.getBytes());
- } else {
- response.getOutputStream().write(bytes);
+ } else {
+ response.getOutputStream().write(bytes);
+ }
}
}
diff --git a/src/main/java/org/traccar/web/ResponseWrapper.java b/src/main/java/org/traccar/web/ResponseWrapper.java
index 7c06b67b8..c6179a33e 100644
--- a/src/main/java/org/traccar/web/ResponseWrapper.java
+++ b/src/main/java/org/traccar/web/ResponseWrapper.java
@@ -75,8 +75,9 @@ public class ResponseWrapper extends HttpServletResponseWrapper {
public byte[] getCapture() throws IOException {
if (output != null) {
output.close();
+ return capture.toByteArray();
}
- return capture.toByteArray();
+ return null;
}
}