Skip to content

Commit 7ffd9cd

Browse files
bkonyiCommit Queue
authored andcommitted
[ Observatory ] Fix connection URI building logic to handle trailing '/'
Fixes #61091 Change-Id: Iddfa3892e4af8e6929d2b792df6226fb1609543a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439805 Reviewed-by: Alexander Aprelev <[email protected]> Auto-Submit: Ben Konyi <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent 0541ad3 commit 7ffd9cd

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

pkg/observatory/lib/src/elements/vm_connect.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,21 @@ class VMConnectElement extends CustomElement implements Renderable {
158158
}
159159
try {
160160
Uri uri = Uri.parse(networkAddress);
161+
// We massage this URI in various places throughout the codebase,
162+
// sometimes rather naively. We remove any trailing '/' to normalize the
163+
// URI to avoid situations where URIs can be constructed with two
164+
// consecutive slashes which can cause authentication code checks to fail
165+
// (e.g., http://127.0.0.1:8080/oOR_LvT4RT4=//getVMTimeline).
166+
//
167+
// See https://github.com/dart-lang/sdk/issues/61091#issuecomment-3058991929
168+
var path = uri.path;
169+
if (path.endsWith('/')) {
170+
path = path.substring(0, path.length - 1);
171+
}
161172
if (uri.path.endsWith('/ws')) {
162-
return 'ws://${uri.authority}${uri.path}';
173+
return 'ws://${uri.authority}$path';
163174
}
164-
return 'ws://${uri.authority}${uri.path}/ws';
175+
return 'ws://${uri.authority}$path/ws';
165176
} catch (e) {
166177
print('caught exception with: $networkAddress -- $e');
167178
return networkAddress;

0 commit comments

Comments
 (0)