Skip to content

Commit 8e2f557

Browse files
committed
Don't auto-download executables
1 parent 2e5d9c1 commit 8e2f557

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Telegram/ViewModels/MessageDelegate.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public override IDispatcherContext Dispatcher
6565

6666

6767

68+
private static readonly string _executableExtensions = "ad ade adp ahk app application appref-ms asp aspx asx bas bat bin cab cdxml cer cfg cgi chi chm cmd cnt com conf cpl crt csh der diagcab dll drv eml exe fon fxp gadget grp hlp hpj hta htt inf ini ins inx isp isu its jar jnlp job js jse jsp key ksh lexe library-ms lnk local lua mad maf mag mam manifest maq mar mas mat mau mav maw mcf mda mdb mde mdt mdw mdz mht mhtml mjs mmc mof msc msg msh msh1 msh2 msh1xml msh2xml mshxml msi msp mst ops osd paf pcd phar php php3 php4 php5 php7 phps php-s pht phtml pif pl plg pm pod prf prg ps1 ps2 ps1xml ps2xml psc1 psc2 psd1 psm1 pssc pst py py3 pyc pyd pyi pyo pyw pyzw pyz rb reg rgs scf scr sct search-ms settingcontent-ms sh shb shs slk sys swf t tmp u3p url vb vbe vbp vbs vbscript vdx vsmacros vsd vsdm vsdx vss vssm vssx vst vstm vstx vsw vsx vtx website wlua ws wsc wsf wsh xbap xll xlsb xlsm xnk xs";
69+
6870
public virtual bool CanBeDownloaded(object content, File file)
6971
{
7072
var chat = Chat;
@@ -83,6 +85,12 @@ public virtual bool CanBeDownloaded(object content, File file)
8385
}
8486
else if (content is Document document)
8587
{
88+
var extension = System.IO.Path.GetExtension(document.FileName);
89+
if (_executableExtensions.Contains(extension.TrimStart('.')))
90+
{
91+
return false;
92+
}
93+
8694
return Settings.AutoDownload.ShouldDownloadDocument(GetChatType(chat), document.DocumentValue.Size);
8795
}
8896
else if (content is Photo photo)

0 commit comments

Comments
 (0)