hardened the restriction to image loading to avoid external resources in RSTextBrowser

This commit is contained in:
csoler 2016-01-13 00:08:27 -05:00
parent d55993d1e4
commit 2a8fc7fe01

View file

@ -74,16 +74,31 @@ void RSTextBrowser::paintEvent(QPaintEvent *event)
QVariant RSTextBrowser::loadResource(int type, const QUrl &name) QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
{ {
std::cerr << "TEXTBROWSER loading ressource: type=" << type << " url=" << name.toString().toStdString() << std::endl; std::cerr << "TEXTBROWSER: load ressource request: type=" << type << " scheme=" << name.scheme().toStdString() << ", url=" << name.toString().toStdString() << std::endl;
if (mShowImages || type != QTextDocument::ImageResource || name.scheme().compare("data", Qt::CaseInsensitive) != 0) { // case 1: always trust the image if it comes from an internal resource
if(name.scheme().compare("qrc",Qt::CaseInsensitive)==0 && type == QTextDocument::ImageResource)
{
std::cerr << "loading because it's qrc..." << std::endl;
return QTextBrowser::loadResource(type, name); return QTextBrowser::loadResource(type, name);
} }
if (mImageBlockWidget) { // case 2: only display if the ser allows it
mImageBlockWidget->show();
if(name.scheme().compare("data",Qt::CaseInsensitive)==0 && mShowImages)
{
std::cerr << "loading because it's data and mShowImages is true..." << std::endl;
return QTextBrowser::loadResource(type, name);
} }
// case 3: otherwise, do not display
std::cerr << "not loading " << std::endl;
if (mImageBlockWidget)
mImageBlockWidget->show();
return QPixmap(":/trolltech/styles/commonstyle/images/file-16.png"); return QPixmap(":/trolltech/styles/commonstyle/images/file-16.png");
} }