File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import io .sentry .JsonObjectReader ;
55import io .sentry .SentryLevel ;
66import io .sentry .SentryOptions ;
7+ import java .io .IOException ;
78import java .io .StringReader ;
89import java .io .StringWriter ;
910import java .util .ArrayList ;
@@ -56,7 +57,7 @@ private GraphqlUtils() {}
5657 final @ NotNull StringWriter writer = new StringWriter ();
5758 options .getSerializer ().serialize (filtered , writer );
5859 return writer .toString ();
59- } catch (Throwable e ) {
60+ } catch (IOException | NumberFormatException e ) {
6061 options .getLogger ().log (SentryLevel .ERROR , "Failed to filter GraphQL request body." , e );
6162 return null ;
6263 }
Original file line number Diff line number Diff line change 44
55import io .sentry .HttpStatusCodeRange ;
66import io .sentry .KeyValueCollectionBehavior ;
7+ import java .io .UnsupportedEncodingException ;
78import java .net .URLDecoder ;
89import java .util .Arrays ;
910import java .util .LinkedHashMap ;
@@ -127,7 +128,7 @@ public static boolean containsSensitiveHeader(final @NotNull String header) {
127128 private static @ NotNull String decodeQueryParamName (final @ NotNull String name ) {
128129 try {
129130 return URLDecoder .decode (name , "UTF-8" );
130- } catch (Throwable ignored ) {
131+ } catch (IllegalArgumentException | UnsupportedEncodingException ignored ) {
131132 return name ;
132133 }
133134 }
Original file line number Diff line number Diff line change @@ -82,6 +82,15 @@ class GraphqlUtilsTest {
8282 assertThat(result).isNull()
8383 }
8484
85+ @Test
86+ fun `returns null for a GraphQL request body containing a malformed unicode escape` () {
87+ val options = SentryOptions ().also { it.dataCollection.graphql.setDocument(false ) }
88+
89+ val result = GraphqlUtils .filterRequestBody(""" {"query":"\u12G4"}""" , options)
90+
91+ assertThat(result).isNull()
92+ }
93+
8594 private companion object {
8695 const val REQUEST_BODY =
8796 """ {"operationName":"GetUser","variables":{"id":"123"},"query":"query { viewer { name } }"}"""
You can’t perform that action at this time.
0 commit comments