mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
Fixed loading of external emoticons
- path comparison was Linux specific, also it had problems with relative paths - name.scheme() returns empty string in this case, check if the url really points to a file instead
This commit is contained in:
parent
8b22924b25
commit
5fd1de0011
@ -102,11 +102,14 @@ QVariant RSTextBrowser::loadResource(int type, const QUrl &name)
|
|||||||
|
|
||||||
// case 2: always trust the image if it comes from local Config or Data directories.
|
// case 2: always trust the image if it comes from local Config or Data directories.
|
||||||
|
|
||||||
if(name.scheme().compare("file",Qt::CaseInsensitive)==0 && type == QTextDocument::ImageResource) {
|
if(type == QTextDocument::ImageResource) {
|
||||||
if (name.path().startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).absolutePath().prepend("/"),Qt::CaseInsensitive)
|
QFileInfo fi = QFileInfo(name.path());
|
||||||
|| name.path().startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).absolutePath().prepend("/"),Qt::CaseInsensitive))
|
if(fi.exists() && fi.isFile()) {
|
||||||
|
QString cpath = fi.canonicalFilePath();
|
||||||
|
if (cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::ConfigDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive)
|
||||||
|
|| cpath.startsWith(QDir(QString::fromUtf8(RsAccounts::DataDirectory().c_str())).canonicalPath(),Qt::CaseInsensitive))
|
||||||
return QTextBrowser::loadResource(type, name);
|
return QTextBrowser::loadResource(type, name);
|
||||||
}
|
}}
|
||||||
|
|
||||||
// case 3: only display if the user allows it. Data resources can be bad (svg bombs) but we filter them out globally at the network layer.
|
// case 3: only display if the user allows it. Data resources can be bad (svg bombs) but we filter them out globally at the network layer.
|
||||||
// It would be good to add here a home-made resource loader that only loads images and not svg crap, just in case.
|
// It would be good to add here a home-made resource loader that only loads images and not svg crap, just in case.
|
||||||
|
Loading…
Reference in New Issue
Block a user