aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-09-20 23:40:42 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-09-20 23:40:42 -0700
commite16022362777dc62fd77e95c0db0807c3be4ea2c (patch)
tree76c156d811f1f9f476aa3b2849c3731ce5952b2c
parentb00588e98cc4ab5254dca1c6e69829de6e1fd993 (diff)
downloadbun-e16022362777dc62fd77e95c0db0807c3be4ea2c.tar.gz
bun-e16022362777dc62fd77e95c0db0807c3be4ea2c.tar.zst
bun-e16022362777dc62fd77e95c0db0807c3be4ea2c.zip
In http client, use .toOwnedSlice() instead of potentially re-using the WTFString here
-rw-r--r--src/http_client_async.zig11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index 3cc044003..1b03483a0 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -3488,11 +3488,14 @@ pub fn handleResponseMetadata(
);
defer new_url_.deref();
- if (new_url_.utf8ByteLength() > url_buf.data.len) {
- return error.RedirectURLTooLong;
+ if (new_url_.isEmpty()) {
+ return error.InvalidRedirectURL;
}
- const new_url = new_url_.toUTF8(fba.allocator());
- this.url = URL.parse(new_url.slice());
+
+ const new_url = new_url_.toOwnedSlice(fba.allocator()) catch {
+ return error.RedirectURLTooLong;
+ };
+ this.url = URL.parse(new_url);
is_same_origin = strings.eqlCaseInsensitiveASCII(strings.withoutTrailingSlash(this.url.origin), strings.withoutTrailingSlash(original_url.origin), true);
deferred_redirect.* = this.redirect;