Skip to content

Commit 476697c

Browse files
committed
Drop query and fragment from WebSocket cookie lookup URI
1 parent 4de7a58 commit 476697c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

  • packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/websocket

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,9 @@ public class WebSocketModule(context: ReactApplicationContext) :
495495

496496
/**
497497
* Get the URI used to look up cookies for a specific WebSocket URI, keeping its path so that
498-
* path-scoped cookies are matched correctly
498+
* path-scoped cookies are matched correctly. Query and fragment are dropped since cookies are
499+
* scoped by path, not by query or fragment (RFC 6265). userInfo is also dropped so that
500+
* credentials embedded in the URL are never forwarded to the cookie store.
499501
*
500502
* @param uri
501503
* @return A URI with the endpoint converted to HTTP protocol (http[s]://host[:port]/path)
@@ -509,8 +511,8 @@ public class WebSocketModule(context: ReactApplicationContext) :
509511
requestURI.host,
510512
requestURI.port,
511513
requestURI.path,
512-
requestURI.query,
513-
requestURI.fragment,
514+
null,
515+
null,
514516
)
515517
} catch (e: URISyntaxException) {
516518
throw IllegalArgumentException("Unable to get cookie lookup URI from $uri")

0 commit comments

Comments
 (0)