Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ SentryAndroid.init(
### Fixes

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

### Internal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.http.MediaType;
import org.springframework.util.InvalidMimeTypeException;
import org.springframework.util.MimeType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
Expand Down Expand Up @@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
}

private static boolean shouldCacheMimeType(String contentType) {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
try {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
} catch (InvalidMimeTypeException e) {
return false;
}
}

static final class RequestBodyExtractingEventProcessor implements EventProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ class SentrySpringFilterTest {
body = "x".repeat(10001),
expectedToBeCached = false,
),
TestParams(
maxRequestBodySize = MEDIUM,
body = "xxx",
expectedToBeCached = false,
contentType = "invalid",
),
TestParams(
maxRequestBodySize = ALWAYS,
body = "x".repeat(10001),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.http.MediaType;
import org.springframework.util.InvalidMimeTypeException;
import org.springframework.util.MimeType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
Expand Down Expand Up @@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
}

private static boolean shouldCacheMimeType(String contentType) {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
try {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
} catch (InvalidMimeTypeException e) {
return false;
}
}

static final class RequestBodyExtractingEventProcessor implements EventProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ class SentrySpringFilterTest {
body = "x".repeat(10001),
expectedToBeCached = false,
),
TestParams(
maxRequestBodySize = MEDIUM,
body = "xxx",
expectedToBeCached = false,
contentType = "invalid",
),
TestParams(
maxRequestBodySize = ALWAYS,
body = "x".repeat(10001),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.http.MediaType;
import org.springframework.util.InvalidMimeTypeException;
import org.springframework.util.MimeType;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingRequestWrapper;
Expand Down Expand Up @@ -131,8 +132,12 @@ && shouldCacheMimeType(contentType)
}

private static boolean shouldCacheMimeType(String contentType) {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
try {
return MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_JSON)
|| MimeType.valueOf(contentType).isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED);
} catch (InvalidMimeTypeException e) {
return false;
}
}

static final class RequestBodyExtractingEventProcessor implements EventProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ class SentrySpringFilterTest {
body = "x".repeat(10001),
expectedToBeCached = false,
),
TestParams(
maxRequestBodySize = MEDIUM,
body = "xxx",
expectedToBeCached = false,
contentType = "invalid",
),
TestParams(
maxRequestBodySize = ALWAYS,
body = "x".repeat(10001),
Expand Down
Loading