File tree Expand file tree Collapse file tree 9 files changed +43
-9
lines changed
main/java/io/sentry/spring7
test/kotlin/io/sentry/spring7
sentry-spring-jakarta/src
main/java/io/sentry/spring/jakarta
test/kotlin/io/sentry/spring/jakarta
main/java/io/sentry/spring
test/kotlin/io/sentry/spring Expand file tree Collapse file tree 9 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 1- * @ adinauer @ romtsn @ stefanosiano @ markushi @ lcian
1+ * @ adinauer @ romtsn @ markushi @ lcian
Original file line number Diff line number Diff line change 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
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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 2626import org .jetbrains .annotations .NotNull ;
2727import org .jetbrains .annotations .Nullable ;
2828import org .springframework .http .MediaType ;
29+ import org .springframework .util .InvalidMimeTypeException ;
2930import org .springframework .util .MimeType ;
3031import org .springframework .web .filter .OncePerRequestFilter ;
3132import 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 {
Original file line number Diff line number Diff 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 ),
Original file line number Diff line number Diff line change 2626import org .jetbrains .annotations .NotNull ;
2727import org .jetbrains .annotations .Nullable ;
2828import org .springframework .http .MediaType ;
29+ import org .springframework .util .InvalidMimeTypeException ;
2930import org .springframework .util .MimeType ;
3031import org .springframework .web .filter .OncePerRequestFilter ;
3132import 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 {
Original file line number Diff line number Diff 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 ),
Original file line number Diff line number Diff line change 2626import org .jetbrains .annotations .NotNull ;
2727import org .jetbrains .annotations .Nullable ;
2828import org .springframework .http .MediaType ;
29+ import org .springframework .util .InvalidMimeTypeException ;
2930import org .springframework .util .MimeType ;
3031import org .springframework .web .filter .OncePerRequestFilter ;
3132import 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 {
Original file line number Diff line number Diff 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 ),
You can’t perform that action at this time.
0 commit comments