SEBSERV-549 fixed. was introduced by fix of SEBSERV-515 + code cleanup

This commit is contained in:
anhefti 2024-06-24 13:23:19 +02:00
parent d528f66afa
commit 99bf2f25da
2 changed files with 22 additions and 48 deletions

39
pom.xml
View file

@ -70,7 +70,7 @@
<profile> <profile>
<id>let_reporting</id> <id>let_reporting</id>
<properties> <properties>
<java.version>1.8</java.version> <java.version>17</java.version>
</properties> </properties>
<build> <build>
<plugins> <plugins>
@ -79,8 +79,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>1.8</source> <release>${java.version}</release>
<target>1.8</target> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
@ -89,6 +89,9 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<systemPropertyVariables>
<file.encoding>UTF-8</file.encoding>
</systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
@ -119,27 +122,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
<configuration>
<effort>Max</effort>
<failOnError>false</failOnError>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>findbugs-excludes.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<id>analyze-compile</id>
<phase>compile</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>-->
<plugin> <plugin>
<groupId>com.github.spotbugs</groupId> <groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId> <artifactId>spotbugs-maven-plugin</artifactId>
@ -163,7 +145,7 @@
<plugin> <plugin>
<groupId>org.jacoco</groupId> <groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId> <artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version> <version>0.8.12</version>
<executions> <executions>
<execution> <execution>
<id>prepare-agent</id> <id>prepare-agent</id>
@ -367,13 +349,18 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId> <artifactId>commons-text</artifactId>
<version>1.8</version> <version>1.10.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId> <groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId> <artifactId>bucket4j-core</artifactId>
<version>4.10.0</version> <version>4.10.0</version>
</dependency> </dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- Testing --> <!-- Testing -->

View file

@ -9,7 +9,6 @@
package ch.ethz.seb.sebserver.gbl.util; package ch.ethz.seb.sebserver.gbl.util;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
@ -404,12 +403,7 @@ public final class Utils {
return value; return value;
} }
try { return URLEncoder.encode(value, StandardCharsets.UTF_8);
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
} catch (final UnsupportedEncodingException e) {
log.error("Failed to encode FormURL_UTF_8 for: {}", value, e);
return value;
}
} }
public static String decodeFormURL_UTF_8(final String value) { public static String decodeFormURL_UTF_8(final String value) {
@ -417,16 +411,11 @@ public final class Utils {
return value; return value;
} }
try { return URLDecoder.decode(
return URLDecoder.decode( (value.indexOf('+') >= 0)
(value.indexOf('+') >= 0) ? value.replaceAll("\\+", "%2b")
? value.replaceAll("\\+", "%2b") : value,
: value, StandardCharsets.UTF_8);
StandardCharsets.UTF_8.name());
} catch (final UnsupportedEncodingException e) {
log.error("Failed to decode FormURL_UTF_8 for: {}", value, e);
return value;
}
} }
public static void clearCharArray(final char[] array) { public static void clearCharArray(final char[] array) {
@ -656,12 +645,10 @@ public final class Utils {
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
for (String key : attributes.keySet()) { for (final String key : attributes.keySet()) {
List<String> values = attributes.get(key); final List<String> values = attributes.get(key);
if (values != null) { if (values != null) {
for (int i = 0; i < values.size(); i++) { values.replaceAll(Utils::encodeFormURL_UTF_8);
values.set(i, encodeFormURL_UTF_8(values.get(i)));
}
} }
} }