mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
net: Do not send data
scheme requests to DevTools (#39318)
Simple check to not send data urls to devtools. Testing: Looked at reddit.com which sends data url and tested it with this fix. Fixes: Should fix https://github.com/servo/servo/issues/39127. --------- Signed-off-by: Narfinger <Narfinger@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
601ad7e5c6
commit
3ccb7540c0
3 changed files with 19 additions and 1 deletions
|
@ -260,7 +260,6 @@ pub async fn main_fetch(
|
|||
) -> Response {
|
||||
// Step 1: Let request be fetchParam's request.
|
||||
let request = &mut fetch_params.request;
|
||||
// send early HTTP request to DevTools
|
||||
send_early_httprequest_to_devtools(request, context);
|
||||
// Step 2: Let response be null.
|
||||
let mut response = None;
|
||||
|
|
|
@ -430,6 +430,10 @@ pub fn send_request_to_devtools(
|
|||
msg: ChromeToDevtoolsControlMsg,
|
||||
devtools_chan: &Sender<DevtoolsControlMsg>,
|
||||
) {
|
||||
if matches!(msg, ChromeToDevtoolsControlMsg::NetworkEvent(_, ref network_event) if !network_event.forward_to_devtools())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if let Err(e) = devtools_chan.send(DevtoolsControlMsg::FromChrome(msg)) {
|
||||
error!("DevTools send failed: {e}");
|
||||
}
|
||||
|
@ -493,6 +497,10 @@ pub fn send_response_values_to_devtools(
|
|||
}
|
||||
|
||||
pub fn send_early_httprequest_to_devtools(request: &Request, context: &FetchContext) {
|
||||
// Do not forward data requests to devtools
|
||||
if request.url().scheme() == "data" {
|
||||
return;
|
||||
}
|
||||
if let (Some(devtools_chan), Some(browsing_context_id), Some(pipeline_id)) = (
|
||||
context.devtools_chan.as_ref(),
|
||||
request.target_webview_id.map(|id| id.into()),
|
||||
|
|
|
@ -473,6 +473,17 @@ pub enum NetworkEvent {
|
|||
HttpResponse(HttpResponse),
|
||||
}
|
||||
|
||||
impl NetworkEvent {
|
||||
pub fn forward_to_devtools(&self) -> bool {
|
||||
!matches!(self, NetworkEvent::HttpRequest(http_request) if http_request.url.scheme() == "data") ||
|
||||
match self {
|
||||
NetworkEvent::HttpRequest(http_request) => http_request.url.scheme() != "data",
|
||||
NetworkEvent::HttpRequestUpdate(..) => true,
|
||||
NetworkEvent::HttpResponse(..) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TimelineMarker {
|
||||
pub fn start(name: String) -> StartedTimelineMarker {
|
||||
StartedTimelineMarker {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue