@@ -473,6 +473,37 @@ unsigned RemoveFilesFromAddons(void* Data)
473473 return 1 ;
474474}
475475
476+ static bool MountingCheck (const char * szStrFile)
477+ {
478+ const char * ext = strrchr (szStrFile, ' .' );
479+ if (!ext || !ext[1 ])
480+ {
481+ // No extension => deny
482+ return false ;
483+ }
484+
485+ // Skip the dot
486+ ext = ext + 1 ;
487+
488+ // Allowed extensions (lowercase). Add or remove as needed.
489+ const char * allowedExts[] = {
490+ " wad" , " wav" , " mp3" , " ogg"
491+ };
492+
493+ const size_t allowedCount = sizeof (allowedExts) / sizeof (allowedExts[0 ]);
494+
495+ bool bAllowed = false ;
496+ for (size_t i = 0 ; i < allowedCount; ++i)
497+ {
498+ if (Q_stricmp (ext, allowedExts[i]) == 0 )
499+ {
500+ bAllowed = true ;
501+ break ;
502+ }
503+ }
504+ return bAllowed;
505+ }
506+
476507void CGameUIViewport::MountWorkshopItem (vgui2::WorkshopItem WorkshopFile, const char * szPath, const char * szRootPath)
477508{
478509 // Copies files to zp_addon,
@@ -511,10 +542,11 @@ void CGameUIViewport::MountWorkshopItem(vgui2::WorkshopItem WorkshopFile, const
511542 if (vgui2::FStrEq (strFile, " ." ) || vgui2::FStrEq (strFile, " .." ))
512543 bIsValidFile = false ;
513544
514- // If we are a root dir, ignore.
515- // We do NOT want to override any CFG files and so on.
545+ // If we are a root dir.
516546 if (bIsRoot && !g_pFullFileSystem->FindIsDirectory (fh))
517- bIsValidFile = false ;
547+ {
548+ bIsValidFile = MountingCheck (strFile);
549+ }
518550 // If root, and is a dir, make sure we only allow certain folders.
519551 else if (bIsRoot && g_pFullFileSystem->FindIsDirectory (fh))
520552 {
@@ -659,7 +691,12 @@ bool CGameUIViewport::ShouldAutoMount(PublishedFileId_t nWorkshopID)
659691 KeyValuesAD autodel (pAddonList);
660692 if (pAddonList->LoadFromFile (g_pFullFileSystem, " addonlist.txt" , " WORKSHOP" ))
661693 {
694+ bool bShouldMount = false ;
662695 std::string strWorkshopID (std::to_string (nWorkshopID));
696+ KeyValues* pKey = pAddonList->FindKey (strWorkshopID.c_str ());
697+ if (!pKey)
698+ bShouldMount = true ;
699+
663700 if (!pAddonList->FindKey (strWorkshopID.c_str ()))
664701 return true ;
665702 }
0 commit comments