Add some more open file warnings.
This commit is contained in:
parent
1fdfa94497
commit
9697567b8d
|
@ -2271,6 +2271,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_language_not_ready_link" = "translations platform";
|
"lng_language_not_ready_link" = "translations platform";
|
||||||
|
|
||||||
"lng_launch_exe_warning" = "This file has a {extension} extension.\nAre you sure you want to run it?";
|
"lng_launch_exe_warning" = "This file has a {extension} extension.\nAre you sure you want to run it?";
|
||||||
|
"lng_launch_svg_warning" = "Opening this file can potentially expose your IP address to its sender. Continue?";
|
||||||
"lng_launch_exe_sure" = "Run";
|
"lng_launch_exe_sure" = "Run";
|
||||||
"lng_launch_exe_dont_ask" = "Don't ask me again";
|
"lng_launch_exe_dont_ask" = "Don't ask me again";
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,8 @@ QByteArray Settings::serialize() const {
|
||||||
<< qint32(_notifyFromAll ? 1 : 0)
|
<< qint32(_notifyFromAll ? 1 : 0)
|
||||||
<< qint32(_nativeWindowFrame.current() ? 1 : 0)
|
<< qint32(_nativeWindowFrame.current() ? 1 : 0)
|
||||||
<< qint32(_systemDarkModeEnabled.current() ? 1 : 0)
|
<< qint32(_systemDarkModeEnabled.current() ? 1 : 0)
|
||||||
<< _callVideoInputDeviceId;
|
<< _callVideoInputDeviceId
|
||||||
|
<< qint32(_ipRevealWarning ? 1 : 0);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +177,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 notifyFromAll = _notifyFromAll ? 1 : 0;
|
qint32 notifyFromAll = _notifyFromAll ? 1 : 0;
|
||||||
qint32 nativeWindowFrame = _nativeWindowFrame.current() ? 1 : 0;
|
qint32 nativeWindowFrame = _nativeWindowFrame.current() ? 1 : 0;
|
||||||
qint32 systemDarkModeEnabled = _systemDarkModeEnabled.current() ? 1 : 0;
|
qint32 systemDarkModeEnabled = _systemDarkModeEnabled.current() ? 1 : 0;
|
||||||
|
qint32 ipRevealWarning = _ipRevealWarning ? 1 : 0;
|
||||||
|
|
||||||
stream >> themesAccentColors;
|
stream >> themesAccentColors;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -259,6 +261,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> callVideoInputDeviceId;
|
stream >> callVideoInputDeviceId;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> ipRevealWarning;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -318,6 +323,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
_includeMutedCounter = (includeMutedCounter == 1);
|
_includeMutedCounter = (includeMutedCounter == 1);
|
||||||
_countUnreadMessages = (countUnreadMessages == 1);
|
_countUnreadMessages = (countUnreadMessages == 1);
|
||||||
_exeLaunchWarning = (exeLaunchWarning == 1);
|
_exeLaunchWarning = (exeLaunchWarning == 1);
|
||||||
|
_ipRevealWarning = (ipRevealWarning == 1);
|
||||||
_notifyAboutPinned = (notifyAboutPinned == 1);
|
_notifyAboutPinned = (notifyAboutPinned == 1);
|
||||||
_loopAnimatedStickers = (loopAnimatedStickers == 1);
|
_loopAnimatedStickers = (loopAnimatedStickers == 1);
|
||||||
_largeEmoji = (largeEmoji == 1);
|
_largeEmoji = (largeEmoji == 1);
|
||||||
|
@ -468,6 +474,7 @@ void Settings::resetOnLastLogout() {
|
||||||
_soundOverrides = {};
|
_soundOverrides = {};
|
||||||
|
|
||||||
_exeLaunchWarning = true;
|
_exeLaunchWarning = true;
|
||||||
|
_ipRevealWarning = true;
|
||||||
_loopAnimatedStickers = true;
|
_loopAnimatedStickers = true;
|
||||||
_largeEmoji = true;
|
_largeEmoji = true;
|
||||||
_replaceEmoji = true;
|
_replaceEmoji = true;
|
||||||
|
|
|
@ -255,6 +255,12 @@ public:
|
||||||
void setExeLaunchWarning(bool warning) {
|
void setExeLaunchWarning(bool warning) {
|
||||||
_exeLaunchWarning = warning;
|
_exeLaunchWarning = warning;
|
||||||
}
|
}
|
||||||
|
[[nodiscard]] bool ipRevealWarning() const {
|
||||||
|
return _ipRevealWarning;
|
||||||
|
}
|
||||||
|
void setIpRevealWarning(bool warning) {
|
||||||
|
_ipRevealWarning = warning;
|
||||||
|
}
|
||||||
[[nodiscard]] bool loopAnimatedStickers() const {
|
[[nodiscard]] bool loopAnimatedStickers() const {
|
||||||
return _loopAnimatedStickers;
|
return _loopAnimatedStickers;
|
||||||
}
|
}
|
||||||
|
@ -513,6 +519,7 @@ private:
|
||||||
Ui::InputSubmitSettings _sendSubmitWay;
|
Ui::InputSubmitSettings _sendSubmitWay;
|
||||||
base::flat_map<QString, QString> _soundOverrides;
|
base::flat_map<QString, QString> _soundOverrides;
|
||||||
bool _exeLaunchWarning = true;
|
bool _exeLaunchWarning = true;
|
||||||
|
bool _ipRevealWarning = true;
|
||||||
bool _loopAnimatedStickers = true;
|
bool _loopAnimatedStickers = true;
|
||||||
rpl::variable<bool> _largeEmoji = true;
|
rpl::variable<bool> _largeEmoji = true;
|
||||||
rpl::variable<bool> _replaceEmoji = true;
|
rpl::variable<bool> _replaceEmoji = true;
|
||||||
|
|
|
@ -74,15 +74,15 @@ void LaunchWithWarning(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &name,
|
const QString &name,
|
||||||
HistoryItem *item) {
|
HistoryItem *item) {
|
||||||
|
const auto isExecutable = Data::IsExecutableName(name);
|
||||||
|
const auto isIpReveal = Data::IsIpRevealingName(name);
|
||||||
|
auto &app = Core::App();
|
||||||
const auto warn = [&] {
|
const auto warn = [&] {
|
||||||
if (!Data::IsExecutableName(name)) {
|
if (item && item->history()->peer->isVerified()) {
|
||||||
return false;
|
|
||||||
} else if (!Core::App().settings().exeLaunchWarning()) {
|
|
||||||
return false;
|
|
||||||
} else if (item && item->history()->peer->isVerified()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return (isExecutable && app.settings().exeLaunchWarning())
|
||||||
|
|| (isIpReveal && app.settings().ipRevealWarning());
|
||||||
}();
|
}();
|
||||||
const auto extension = '.' + Data::FileExtension(name);
|
const auto extension = '.' + Data::FileExtension(name);
|
||||||
if (Platform::IsWindows() && extension == u"."_q) {
|
if (Platform::IsWindows() && extension == u"."_q) {
|
||||||
|
@ -99,20 +99,27 @@ void LaunchWithWarning(
|
||||||
File::Launch(name);
|
File::Launch(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto callback = [=](bool checked) {
|
const auto callback = [=, &app](bool checked) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
Core::App().settings().setExeLaunchWarning(false);
|
if (isExecutable) {
|
||||||
Core::App().saveSettingsDelayed();
|
app.settings().setExeLaunchWarning(false);
|
||||||
|
} else if (isIpReveal) {
|
||||||
|
app.settings().setIpRevealWarning(false);
|
||||||
|
}
|
||||||
|
app.saveSettingsDelayed();
|
||||||
}
|
}
|
||||||
File::Launch(name);
|
File::Launch(name);
|
||||||
};
|
};
|
||||||
Ui::show(Box<ConfirmDontWarnBox>(
|
auto text = isExecutable
|
||||||
tr::lng_launch_exe_warning(
|
? tr::lng_launch_exe_warning(
|
||||||
lt_extension,
|
lt_extension,
|
||||||
rpl::single(Ui::Text::Bold(extension)),
|
rpl::single(Ui::Text::Bold(extension)),
|
||||||
Ui::Text::WithEntities),
|
Ui::Text::WithEntities)
|
||||||
|
: tr::lng_launch_svg_warning(Ui::Text::WithEntities);
|
||||||
|
Ui::show(Box<ConfirmDontWarnBox>(
|
||||||
|
std::move(text),
|
||||||
tr::lng_launch_exe_dont_ask(tr::now),
|
tr::lng_launch_exe_dont_ask(tr::now),
|
||||||
tr::lng_launch_exe_sure(),
|
(isExecutable ? tr::lng_launch_exe_sure : tr::lng_continue)(),
|
||||||
callback));
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1668,17 +1675,17 @@ mpkg pkg scpt scptd xhtm webarchive");
|
||||||
slp zsh");
|
slp zsh");
|
||||||
#else // Q_OS_MAC || Q_OS_UNIX
|
#else // Q_OS_MAC || Q_OS_UNIX
|
||||||
qsl("\
|
qsl("\
|
||||||
ad ade adp app application appref-ms asp asx bas bat bin cdxml cer cfg chi \
|
ad ade adp app application appref-ms asp asx bas bat bin cab cdxml cer cfg \
|
||||||
chm cmd cnt com cpl crt csh der diagcab dll drv eml exe fon fxp gadget grp \
|
chi chm cmd cnt com cpl crt csh der diagcab dll drv eml exe fon fxp gadget \
|
||||||
hlp hpj hta htt inf ini ins inx isp isu its jar jnlp job js jse ksh lnk \
|
grp hlp hpj hta htt inf ini ins inx isp isu its jar jnlp job js jse key ksh \
|
||||||
local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf mda mdb \
|
lnk local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf mda \
|
||||||
mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml msh2xml \
|
mdb mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml \
|
||||||
mshxml msi msp mst ops osd paf pcd phar php php3 php4 php5 php7 phps php-s \
|
msh2xml mshxml msi msp mst ops osd paf pcd phar php php3 php4 php5 php7 phps \
|
||||||
pht phtml pif pl plg pm pod prf prg ps1 ps2 ps1xml ps2xml psc1 psc2 psd1 \
|
php-s pht phtml pif pl plg pm pod prf prg ps1 ps2 ps1xml ps2xml psc1 psc2 \
|
||||||
psm1 pssc pst py py3 pyc pyd pyi pyo pyw pywz pyz rb reg rgs scf scr sct \
|
psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pywz pyz rb reg rgs scf scr \
|
||||||
search-ms settingcontent-ms sh shb shs slk sys t tmp u3p url vb vbe vbp vbs \
|
sct search-ms settingcontent-ms sh shb shs slk sys t tmp u3p url vb vbe vbp \
|
||||||
vbscript vdx vsmacros vsd vsdm vsdx vss vssm vssx vst vstm vstx vsw vsx vtx \
|
vbs vbscript vdx vsmacros vsd vsdm vsdx vss vssm vssx vst vstm vstx vsw vsx \
|
||||||
website ws wsc wsf wsh xbap xll xnk xs");
|
vtx website ws wsc wsf wsh xbap xll xnk xs");
|
||||||
#endif // !Q_OS_MAC && !Q_OS_UNIX
|
#endif // !Q_OS_MAC && !Q_OS_UNIX
|
||||||
const auto list = joined.split(' ');
|
const auto list = joined.split(' ');
|
||||||
return base::flat_set<QString>(list.begin(), list.end());
|
return base::flat_set<QString>(list.begin(), list.end());
|
||||||
|
@ -1689,6 +1696,18 @@ website ws wsc wsf wsh xbap xll xnk xs");
|
||||||
FileExtension(filepath).toLower());
|
FileExtension(filepath).toLower());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsIpRevealingName(const QString &filepath) {
|
||||||
|
static const auto kExtensions = [] {
|
||||||
|
const auto joined = u"htm html svg"_q;
|
||||||
|
const auto list = joined.split(' ');
|
||||||
|
return base::flat_set<QString>(list.begin(), list.end());
|
||||||
|
}();
|
||||||
|
|
||||||
|
return ranges::binary_search(
|
||||||
|
kExtensions,
|
||||||
|
FileExtension(filepath).toLower());
|
||||||
|
}
|
||||||
|
|
||||||
base::binary_guard ReadImageAsync(
|
base::binary_guard ReadImageAsync(
|
||||||
not_null<Data::DocumentMedia*> media,
|
not_null<Data::DocumentMedia*> media,
|
||||||
FnMut<QImage(QImage)> postprocess,
|
FnMut<QImage(QImage)> postprocess,
|
||||||
|
|
|
@ -443,9 +443,10 @@ QString DocumentFileNameForSave(
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
QString FileExtension(const QString &filepath);
|
[[nodiscard]] QString FileExtension(const QString &filepath);
|
||||||
bool IsValidMediaFile(const QString &filepath);
|
[[nodiscard]] bool IsValidMediaFile(const QString &filepath);
|
||||||
bool IsExecutableName(const QString &filepath);
|
[[nodiscard]] bool IsExecutableName(const QString &filepath);
|
||||||
|
[[nodiscard]] bool IsIpRevealingName(const QString &filepath);
|
||||||
base::binary_guard ReadImageAsync(
|
base::binary_guard ReadImageAsync(
|
||||||
not_null<Data::DocumentMedia*> media,
|
not_null<Data::DocumentMedia*> media,
|
||||||
FnMut<QImage(QImage)> postprocess,
|
FnMut<QImage(QImage)> postprocess,
|
||||||
|
|
Loading…
Reference in New Issue