Image uploader mime filter uses urls but doesn't check them (#2855)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Mm2PL 2021-06-13 14:23:13 +00:00 committed by GitHub
parent 3977eb74a6
commit 9fb5ef60d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -16,6 +16,7 @@
- Minor: Added a link to accounts page in settings to "You need to be logged in to send messages" message. (#2862)
- Minor: Switch to Twitch v2 emote API for animated emote support. (#2863)
- Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808)
- Bugfix: Fixed pasting text with URLs included (#1688, #2855)
- Bugfix: Fix reconnecting when IRC write connection is lost (#1831, #2356, #2850)
- Bugfix: Fixed bit emotes not loading in some rare cases. (#2856)

View file

@ -5,6 +5,7 @@
#include "singletons/Settings.hpp"
#include <QMimeData>
#include <QMimeDatabase>
namespace chatterino {
@ -264,14 +265,33 @@ bool ResizingTextEdit::canInsertFromMimeData(const QMimeData *source) const
void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
{
if (source->hasImage() || source->hasUrls())
if (source->hasImage())
{
this->imagePasted.invoke(source);
return;
}
else
else if (source->hasUrls())
{
insertPlainText(source->text());
bool hasUploadable = false;
auto mimeDb = QMimeDatabase();
for (const QUrl url : source->urls())
{
QMimeType mime = mimeDb.mimeTypeForUrl(url);
if (mime.name().startsWith("image"))
{
hasUploadable = true;
break;
}
}
if (hasUploadable)
{
this->imagePasted.invoke(source);
return;
}
}
insertPlainText(source->text());
}
QCompleter *ResizingTextEdit::getCompleter() const