Skip to content

Commit 86b7e6b

Browse files
author
Daniel Herzog
committed
Fixed cleaning up context allocation after getting redirects from a crafted request. I know, it's as awesome as it sounds.
1 parent 15e122a commit 86b7e6b

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/network/network_service.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,25 @@ cls.NetworkLoggerService = function()
246246
if (!ctx)
247247
return;
248248

249+
// Workaround CORE-47687: UrlFinished is missing for urls resulting in a 301 (Moved Permanently) response
250+
var remove_from_allocated_after_update = false;
251+
if (ctx)
252+
{
253+
// Guess what the matching entry is from here. This is normally much harder,
254+
// but we only want to do this workaround in this easy case anyway.
255+
var matching_entry = ctx.get_entries_with_res_id(data.resourceID)[0];
256+
if (matching_entry.events.last &&
257+
matching_entry.events.last.name == "urlredirect")
258+
{
259+
remove_from_allocated_after_update = true;
260+
}
261+
}
262+
249263
ctx.update("responsefinished", data);
250-
// todo: work around CORE-47687 here too. in case the corresponding entry
251-
// has seen a redirect before, it needs to remove the resource id from the allocated list now.
264+
265+
if (remove_from_allocated_after_update)
266+
delete ctx.allocated_res_ids[data.resourceID];
267+
252268
};
253269
this._on_responsefinished_bound = this._on_responsefinished.bind(this, this._on_responsefinished);
254270

@@ -1068,7 +1084,7 @@ cls.NetworkLoggerEntryPrototype = function()
10681084

10691085
this._update_event_urlredirect = function(event)
10701086
{
1071-
// Workaround for CORE-47687
1087+
// Workaround CORE-47687: UrlFinished is missing for urls resulting in a 301 (Moved Permanently) response
10721088
this._set_is_finished_on_responsefinished = true;
10731089
};
10741090

0 commit comments

Comments
 (0)