SL-16638 don't allow downloading files from the built-in browser

meow-7.2.2
Mnikolenko Productengine 2022-01-14 15:36:00 +02:00 committed by Andrey Kleshchev
parent bb71cbed04
commit 257f75d7a3
6 changed files with 62 additions and 44 deletions

View File

@ -102,6 +102,7 @@ BOOL LLFloater360Capture::postBuild()
mWebBrowser = getChild<LLMediaCtrl>("360capture_contents");
mWebBrowser->addObserver(this);
mWebBrowser->setAllowFileDownload(true);
// There is a group of radio buttons that define the quality
// by each having a 'value' that is returns equal to the pixel

View File

@ -46,6 +46,7 @@
#include "lluictrlfactory.h" // LLDefaultChildRegistry
#include "llkeyboard.h"
#include "llviewermenu.h"
#include "llviewermenufile.h" // LLFilePickerThread
// linden library includes
#include "llfocusmgr.h"
@ -105,7 +106,8 @@ LLMediaCtrl::LLMediaCtrl( const Params& p) :
mTrusted(p.trusted_content),
mWindowShade(NULL),
mHoverTextChanged(false),
mContextMenu(NULL)
mContextMenu(NULL),
mAllowFileDownload(false)
{
{
LLColor4 color = p.caret_color().get();
@ -1129,8 +1131,23 @@ void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event)
case MEDIA_EVENT_FILE_DOWNLOAD:
{
//llinfos << "Media event - file download requested - filename is " << self->getFileDownloadFilename() << llendl;
//LLNotificationsUtil::add("MediaFileDownloadUnsupported");
if (mAllowFileDownload)
{
// pick a file from SAVE FILE dialog
// for now the only thing that should be allowed to save is 360s
std::string suggested_filename = self->getFileDownloadFilename();
LLFilePicker::ESaveFilter filter = LLFilePicker::FFSAVE_ALL;
if (suggested_filename.find(".jpg") != std::string::npos || suggested_filename.find(".jpeg") != std::string::npos)
filter = LLFilePicker::FFSAVE_JPEG;
if (suggested_filename.find(".png") != std::string::npos)
filter = LLFilePicker::FFSAVE_PNG;
(new LLMediaFilePicker(self, filter, suggested_filename))->getFile();
}
else
{
LLNotificationsUtil::add("MediaFileDownloadUnsupported");
}
};
break;

View File

@ -151,6 +151,8 @@ public:
void setTrustedContent(bool trusted);
void setAllowFileDownload(bool allow) { mAllowFileDownload = allow; }
// over-rides
virtual BOOL handleKeyHere( KEY key, MASK mask);
virtual BOOL handleKeyUpHere(KEY key, MASK mask);
@ -205,7 +207,8 @@ public:
mClearCache,
mHoverTextChanged,
mDecoupleTextureSize,
mUpdateScrolls;
mUpdateScrolls,
mAllowFileDownload;
std::string mHomePageUrl,
mHomePageMimeType,

View File

@ -78,41 +78,12 @@
#include <boost/bind.hpp> // for SkinFolder listener
#include <boost/signals2.hpp>
class LLMediaFilePicker : public LLFilePickerThread // deletes itself when done
{
public:
LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
: LLFilePickerThread(filter, get_multiple),
mPlugin(plugin->getSharedPrt())
{
}
LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name)
: LLFilePickerThread(filter, proposed_name),
mPlugin(plugin->getSharedPrt())
{
}
virtual void notify(const std::vector<std::string>& filenames)
{
mPlugin->sendPickFileResponse(mResponses);
mPlugin = NULL;
}
private:
boost::shared_ptr<LLPluginClassMedia> mPlugin;
};
void init_threaded_picker_load_dialog(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
{
(new LLMediaFilePicker(plugin, filter, get_multiple))->getFile(); // will delete itself
}
void init_threaded_picker_save_dialog(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, std::string &proposed_name)
{
(new LLMediaFilePicker(plugin, filter, proposed_name))->getFile(); // will delete itself
}
///////////////////////////////////////////////////////////////////////////////
// Move this to its own file.
@ -3237,18 +3208,10 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla
case LLViewerMediaObserver::MEDIA_EVENT_FILE_DOWNLOAD:
{
LL_DEBUGS("Media") << "Media event - file download requested - filename is " << plugin->getFileDownloadFilename() << LL_ENDL;
// pick a file from SAVE FILE dialog
// need a better algorithm that this or else, pass in type of save type
// from event that initiated it - this is okay for now - only thing
// that saves is 360s
std::string suggested_filename = plugin->getFileDownloadFilename();
LLFilePicker::ESaveFilter filter = LLFilePicker::FFSAVE_ALL;
if (suggested_filename.find(".jpg") != std::string::npos || suggested_filename.find(".jpeg") != std::string::npos)
filter = LLFilePicker::FFSAVE_JPEG;
if (suggested_filename.find(".png") != std::string::npos)
filter = LLFilePicker::FFSAVE_PNG;
init_threaded_picker_save_dialog(plugin, filter, suggested_filename);
//unblock media plugin
const std::vector<std::string> empty_response;
plugin->sendPickFileResponse(empty_response);
}
break;

View File

@ -46,6 +46,7 @@
#include "llimagejpeg.h"
#include "llimagetga.h"
#include "llinventorymodel.h" // gInventory
#include "llpluginclassmedia.h"
#include "llresourcedata.h"
#include "lltoast.h"
#include "llfloaterperms.h"
@ -251,6 +252,25 @@ void LLFilePickerReplyThread::notify(const std::vector<std::string>& filenames)
}
}
LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple)
: LLFilePickerThread(filter, get_multiple),
mPlugin(plugin->getSharedPrt())
{
}
LLMediaFilePicker::LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name)
: LLFilePickerThread(filter, proposed_name),
mPlugin(plugin->getSharedPrt())
{
}
void LLMediaFilePicker::notify(const std::vector<std::string>& filenames)
{
mPlugin->sendPickFileResponse(mResponses);
mPlugin = NULL;
}
//============================================================================
#if LL_WINDOWS

View File

@ -37,6 +37,7 @@
#include "llviewerassetupload.h"
class LLTransactionID;
class LLPluginClassMedia;
void init_menu_file();
@ -71,6 +72,7 @@ void assign_defaults_and_show_upload_message(
const std::string& display_name,
std::string& description);
//consider moving all file pickers below to more suitable place
class LLFilePickerThread : public LLThread
{ //multi-threaded file picker (runs system specific file picker in background and calls "notify" from main thread)
public:
@ -127,5 +129,17 @@ private:
file_picked_signal_t* mFailureSignal;
};
class LLMediaFilePicker : public LLFilePickerThread
{
public:
LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple);
LLMediaFilePicker(LLPluginClassMedia* plugin, LLFilePicker::ESaveFilter filter, const std::string &proposed_name);
virtual void notify(const std::vector<std::string>& filenames);
private:
boost::shared_ptr<LLPluginClassMedia> mPlugin;
};
#endif