Skip to content

Commit 168bf8b

Browse files
authored
Merge branch 'main' into dependabot/github_actions/actions/checkout-6
2 parents dcdb1fa + 10be7df commit 168bf8b

File tree

9 files changed

+43
-9
lines changed

9 files changed

+43
-9
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @adinauer @romtsn @stefanosiano @markushi @lcian
1+
* @adinauer @romtsn @markushi @lcian

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
3737

3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # pin@v2
39+
uses: github/codeql-action/init@fdbfb4d2750291e159f0156def62b853c2798ca2 # pin@v2
4040
with:
4141
languages: 'java'
4242

@@ -45,4 +45,4 @@ jobs:
4545
./gradlew buildForCodeQL --no-build-cache
4646
4747
- name: Perform CodeQL Analysis
48-
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # pin@v2
48+
uses: github/codeql-action/analyze@fdbfb4d2750291e159f0156def62b853c2798ca2 # pin@v2

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ SentryAndroid.init(
5959
### Fixes
6060

6161
- Fix missing thread stacks for ANRv1 events ([#4918](https://github.com/getsentry/sentry-java/pull/4918))
62+
- Fix handling of unparseable mime-type on request filter ([#4939](https://github.com/getsentry/sentry-java/pull/4939))
6263

6364
### Internal
6465

sentry-spring-7/src/main/java/io/sentry/spring7/SentrySpringFilter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.jetbrains.annotations.NotNull;
2727
import org.jetbrains.annotations.Nullable;
2828
import org.springframework.http.MediaType;
29+
import org.springframework.util.InvalidMimeTypeException;
2930
import org.springframework.util.MimeType;
3031
import org.springframework.web.filter.OncePerRequestFilter;
3132
import org.springframework.web.util.ContentCachingRequestWrapper;
@@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
131132
}
132133

133134
private static boolean shouldCacheMimeType(String contentType) {
134-
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
135-
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
135+
try {
136+
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
137+
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
138+
} catch (InvalidMimeTypeException e) {
139+
return false;
140+
}
136141
}
137142

138143
static final class RequestBodyExtractingEventProcessor implements EventProcessor {

sentry-spring-7/src/test/kotlin/io/sentry/spring7/SentrySpringFilterTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ class SentrySpringFilterTest {
266266
body = "x".repeat(10001),
267267
expectedToBeCached = false,
268268
),
269+
TestParams(
270+
maxRequestBodySize = MEDIUM,
271+
body = "xxx",
272+
expectedToBeCached = false,
273+
contentType = "invalid",
274+
),
269275
TestParams(
270276
maxRequestBodySize = ALWAYS,
271277
body = "x".repeat(10001),

sentry-spring-jakarta/src/main/java/io/sentry/spring/jakarta/SentrySpringFilter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.jetbrains.annotations.NotNull;
2727
import org.jetbrains.annotations.Nullable;
2828
import org.springframework.http.MediaType;
29+
import org.springframework.util.InvalidMimeTypeException;
2930
import org.springframework.util.MimeType;
3031
import org.springframework.web.filter.OncePerRequestFilter;
3132
import org.springframework.web.util.ContentCachingRequestWrapper;
@@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
131132
}
132133

133134
private static boolean shouldCacheMimeType(String contentType) {
134-
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
135-
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
135+
try {
136+
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
137+
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
138+
} catch (InvalidMimeTypeException e) {
139+
return false;
140+
}
136141
}
137142

138143
static final class RequestBodyExtractingEventProcessor implements EventProcessor {

sentry-spring-jakarta/src/test/kotlin/io/sentry/spring/jakarta/SentrySpringFilterTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ class SentrySpringFilterTest {
266266
body = "x".repeat(10001),
267267
expectedToBeCached = false,
268268
),
269+
TestParams(
270+
maxRequestBodySize = MEDIUM,
271+
body = "xxx",
272+
expectedToBeCached = false,
273+
contentType = "invalid",
274+
),
269275
TestParams(
270276
maxRequestBodySize = ALWAYS,
271277
body = "x".repeat(10001),

sentry-spring/src/main/java/io/sentry/spring/SentrySpringFilter.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.jetbrains.annotations.NotNull;
2727
import org.jetbrains.annotations.Nullable;
2828
import org.springframework.http.MediaType;
29+
import org.springframework.util.InvalidMimeTypeException;
2930
import org.springframework.util.MimeType;
3031
import org.springframework.web.filter.OncePerRequestFilter;
3132
import org.springframework.web.util.ContentCachingRequestWrapper;
@@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
131132
}
132133

133134
private static boolean shouldCacheMimeType(String contentType) {
134-
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
135-
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
135+
try {
136+
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
137+
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
138+
} catch (InvalidMimeTypeException e) {
139+
return false;
140+
}
136141
}
137142

138143
static final class RequestBodyExtractingEventProcessor implements EventProcessor {

sentry-spring/src/test/kotlin/io/sentry/spring/SentrySpringFilterTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ class SentrySpringFilterTest {
266266
body = "x".repeat(10001),
267267
expectedToBeCached = false,
268268
),
269+
TestParams(
270+
maxRequestBodySize = MEDIUM,
271+
body = "xxx",
272+
expectedToBeCached = false,
273+
contentType = "invalid",
274+
),
269275
TestParams(
270276
maxRequestBodySize = ALWAYS,
271277
body = "x".repeat(10001),

0 commit comments

Comments
 (0)