Skip to content

Commit f46a3ab

Browse files
committed
bug: fix Set-Cookie headers incorrectly concatenated with comma separator
Issue is that commas are valid separators in certain headers (Cookie, Set-Cookie,...). Switch to semi-colon separated instead -> this only governs the formatted list that appears in the sentry dashboard so is relatively minor. review comment - #4919 (comment) ./gradlew :sentry-okhttp:test --tests="*SentryOkHttpInterceptorTest.toMap handles duplicate headers correctly*"
1 parent 72f9b9e commit f46a3ab

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sentry-okhttp/src/main/java/io/sentry/okhttp/SentryOkHttpInterceptor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ public open class SentryOkHttpInterceptor(
272272
val value = value(i)
273273
val existingValue = headers[name]
274274
if (existingValue != null) {
275-
// Concatenate duplicate headers with comma separator
276-
headers[name] = "$existingValue, $value"
275+
// Concatenate duplicate headers with semicolon separator
276+
headers[name] = "$existingValue; $value"
277277
} else {
278278
headers[name] = value
279279
}

sentry-okhttp/src/test/java/io/sentry/okhttp/SentryOkHttpInterceptorTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,9 @@ class SentryOkHttpInterceptorTest {
710710
val interceptor = SentryOkHttpInterceptor(fixture.scopes)
711711
val headerMap = with(interceptor) { headers.toMap() }
712712

713-
// Duplicate headers will be collapsed into 1 concatenated entry with ", " separator
714-
assertEquals("sessionId=123, userId=456, theme=dark", headerMap["Set-Cookie"])
715-
assertEquals("text/html, application/json", headerMap["Accept"])
713+
// Duplicate headers will be collapsed into 1 concatenated entry with "; " separator
714+
assertEquals("sessionId=123; userId=456; theme=dark", headerMap["Set-Cookie"])
715+
assertEquals("text/html; application/json", headerMap["Accept"])
716716
assertEquals("value", headerMap["Single-Header"])
717717
}
718718
}

0 commit comments

Comments
 (0)