Skip to content

Commit

Permalink
SEBSERV-549 fixed. was introduced by fix of SEBSERV-515 + code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Jun 24, 2024
1 parent d528f66 commit 99bf2f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 48 deletions.
39 changes: 13 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<profile>
<id>let_reporting</id>
<properties>
<java.version>1.8</java.version>
<java.version>17</java.version>
</properties>
<build>
<plugins>
Expand All @@ -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>

Expand All @@ -89,6 +89,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<systemPropertyVariables>
<file.encoding>UTF-8</file.encoding>
</systemPropertyVariables>
</configuration>
</plugin>

Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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 -->
Expand Down
31 changes: 9 additions & 22 deletions src/main/java/ch/ethz/seb/sebserver/gbl/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -404,29 +403,19 @@ public static String encodeFormURL_UTF_8(final String value) {
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) {
if (StringUtils.isBlank(value)) {
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) {
Expand Down Expand Up @@ -656,12 +645,10 @@ public static String toAppFormUrlEncodedBodyForSPService(final MultiValueMap<Str
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);
}
}

Expand Down

0 comments on commit 99bf2f2

Please sign in to comment.