From b54d9d2b0255b403fe5a758d425fde48cf988cd5 Mon Sep 17 00:00:00 2001 From: mkarolin Date: Wed, 1 Feb 2023 14:55:24 -0500 Subject: [PATCH] Perform download safety check even when user is prompted to save. --- .../browser/download/download_target_determiner.cc | 13 +++++++++++++ ...ser-download-download_target_determiner.cc.patch | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 chromium_src/chrome/browser/download/download_target_determiner.cc create mode 100644 patches/chrome-browser-download-download_target_determiner.cc.patch diff --git a/chromium_src/chrome/browser/download/download_target_determiner.cc b/chromium_src/chrome/browser/download/download_target_determiner.cc new file mode 100644 index 000000000000..76db7ed6c915 --- /dev/null +++ b/chromium_src/chrome/browser/download/download_target_determiner.cc @@ -0,0 +1,13 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +// Prompting the user for download location shouldn't be a factor in determining +// the download's danger level. +#define BRAVE_DOWNLOAD_TARGET_DETERMINER_GET_DANGER_LEVEL \ + true) {} \ + if ( + +#include "src/chrome/browser/download/download_target_determiner.cc" +#undef BRAVE_DOWNLOAD_TARGET_DETERMINER_GET_DANGER_LEVEL diff --git a/patches/chrome-browser-download-download_target_determiner.cc.patch b/patches/chrome-browser-download-download_target_determiner.cc.patch new file mode 100644 index 000000000000..079dc33000e6 --- /dev/null +++ b/patches/chrome-browser-download-download_target_determiner.cc.patch @@ -0,0 +1,12 @@ +diff --git a/chrome/browser/download/download_target_determiner.cc b/chrome/browser/download/download_target_determiner.cc +index 6e2ece915f5b00068b804607d24a0eb39bce8ffd..19a3ed5111d24613941f5c5505694cedabe42884 100644 +--- a/chrome/browser/download/download_target_determiner.cc ++++ b/chrome/browser/download/download_target_determiner.cc +@@ -1253,6 +1253,7 @@ DownloadFileType::DangerLevel DownloadTargetDeterminer::GetDangerLevel( + // contains malware. + if (HasPromptedForPath() || + confirmation_reason_ != DownloadConfirmationReason::NONE || ++ BRAVE_DOWNLOAD_TARGET_DETERMINER_GET_DANGER_LEVEL + !download_->GetForcedFilePath().empty()) + return DownloadFileType::NOT_DANGEROUS; +