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>
<id>let_reporting</id>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>
<build>
<plugins>
@ -79,8 +79,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>${java.version}</release>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
@ -89,6 +89,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<systemPropertyVariables>
<file.encoding>UTF-8</file.encoding>
</systemPropertyVariables>
</configuration>
</plugin>
@ -119,27 +122,6 @@
</execution>
</executions>
</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>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
@ -163,7 +145,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.12</version>
<executions>
<execution>
<id>prepare-agent</id>
@ -367,13 +349,18 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
<version>1.10.0</version>
</dependency>
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<!-- Testing -->

View file

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