mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 04:24:23 +00:00
Use proper fallback value for Mark-of-the-Web URL
References: https://chromium.googlesource.com/chromium/src.git/+/refs/heads/main/components/services/quarantine/quarantine_win.cc#211 https://hg.mozilla.org/mozilla-central/file/bd568ad893882d37f094d43cba3f62c78982cd05/toolkit/components/downloads/DownloadIntegration.sys.mjs#l537
This commit is contained in:
parent
9b924c1931
commit
b4642ca9d3
@ -622,6 +622,8 @@ QString Utils::Misc::zlibVersionString()
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
bool Utils::Misc::applyMarkOfTheWeb(const Path &file, const QString &url)
|
bool Utils::Misc::applyMarkOfTheWeb(const Path &file, const QString &url)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(url.isEmpty() || url.startsWith(u"http:") || url.startsWith(u"https:"));
|
||||||
|
|
||||||
const QString zoneIDStream = file.toString() + u":Zone.Identifier";
|
const QString zoneIDStream = file.toString() + u":Zone.Identifier";
|
||||||
HANDLE handle = ::CreateFileW(zoneIDStream.toStdWString().c_str(), GENERIC_WRITE
|
HANDLE handle = ::CreateFileW(zoneIDStream.toStdWString().c_str(), GENERIC_WRITE
|
||||||
, (FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE)
|
, (FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE)
|
||||||
@ -631,8 +633,9 @@ bool Utils::Misc::applyMarkOfTheWeb(const Path &file, const QString &url)
|
|||||||
|
|
||||||
// 5.6.1 Zone.Identifier Stream Name
|
// 5.6.1 Zone.Identifier Stream Name
|
||||||
// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/6e3f7352-d11c-4d76-8c39-2516a9df36e8
|
// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/6e3f7352-d11c-4d76-8c39-2516a9df36e8
|
||||||
|
const QString hostURL = !url.isEmpty() ? url : u"about:internet"_s;
|
||||||
const QByteArray zoneID = QByteArrayLiteral("[ZoneTransfer]\r\nZoneId=3\r\n")
|
const QByteArray zoneID = QByteArrayLiteral("[ZoneTransfer]\r\nZoneId=3\r\n")
|
||||||
+ (!url.isEmpty() ? u"HostUrl=%1\r\n"_s.arg(url).toUtf8() : QByteArray());
|
+ u"HostUrl=%1\r\n"_s.arg(hostURL).toUtf8();
|
||||||
|
|
||||||
DWORD written = 0;
|
DWORD written = 0;
|
||||||
const BOOL writeResult = ::WriteFile(handle, zoneID.constData(), zoneID.size(), &written, nullptr);
|
const BOOL writeResult = ::WriteFile(handle, zoneID.constData(), zoneID.size(), &written, nullptr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user