Skip to content

Commit 3315b18

Browse files
adinauerclaude
andcommitted
ref(core): Remove broad cookie filtering catches
Let unexpected implementation errors remain visible instead of swallowing fatal JVM errors during deterministic cookie parsing. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6900fba commit 3315b18

1 file changed

Lines changed: 15 additions & 23 deletions

File tree

‎sentry/src/main/java/io/sentry/util/HttpUtils.java‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,20 +148,16 @@ public static boolean containsSensitiveHeader(final @NotNull String header) {
148148
return null;
149149
}
150150

151-
try {
152-
final @NotNull String[] cookieValues = cookies.split(";", -1);
153-
final @NotNull StringBuilder filteredCookies = new StringBuilder();
154-
for (int i = 0; i < cookieValues.length; i++) {
155-
if (i > 0) {
156-
filteredCookies.append(';');
157-
}
158-
filteredCookies.append(
159-
filterCookie(cookieValues[i], behavior, additionalSensitiveCookieNames));
151+
final @NotNull String[] cookieValues = cookies.split(";", -1);
152+
final @NotNull StringBuilder filteredCookies = new StringBuilder();
153+
for (int i = 0; i < cookieValues.length; i++) {
154+
if (i > 0) {
155+
filteredCookies.append(';');
160156
}
161-
return filteredCookies.toString();
162-
} catch (Throwable ignored) {
163-
return SENSITIVE_DATA_SUBSTITUTE;
157+
filteredCookies.append(
158+
filterCookie(cookieValues[i], behavior, additionalSensitiveCookieNames));
164159
}
160+
return filteredCookies.toString();
165161
}
166162

167163
public static @Nullable String filterSetCookie(
@@ -170,19 +166,15 @@ public static boolean containsSensitiveHeader(final @NotNull String header) {
170166
return null;
171167
}
172168

173-
try {
174-
final int attributesSeparator = cookie.indexOf(';');
175-
final @NotNull String cookieValue =
176-
attributesSeparator < 0 ? cookie : cookie.substring(0, attributesSeparator);
177-
if (!isValidCookiePair(cookieValue)) {
178-
return SENSITIVE_DATA_SUBSTITUTE;
179-
}
180-
final @NotNull String attributes =
181-
attributesSeparator < 0 ? "" : cookie.substring(attributesSeparator);
182-
return filterCookie(cookieValue, behavior, null) + attributes;
183-
} catch (Throwable ignored) {
169+
final int attributesSeparator = cookie.indexOf(';');
170+
final @NotNull String cookieValue =
171+
attributesSeparator < 0 ? cookie : cookie.substring(0, attributesSeparator);
172+
if (!isValidCookiePair(cookieValue)) {
184173
return SENSITIVE_DATA_SUBSTITUTE;
185174
}
175+
final @NotNull String attributes =
176+
attributesSeparator < 0 ? "" : cookie.substring(attributesSeparator);
177+
return filterCookie(cookieValue, behavior, null) + attributes;
186178
}
187179

188180
private static @NotNull String filterCookie(

0 commit comments

Comments
 (0)