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
2 changed files with 24 additions and 3 deletions
+1
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: 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) - Minor: Switch to Twitch v2 emote API for animated emote support. (#2863)
- Bugfix: Fixed FFZ emote links for global emotes (#2807, #2808) - 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: Fix reconnecting when IRC write connection is lost (#1831, #2356, #2850)
- Bugfix: Fixed bit emotes not loading in some rare cases. (#2856) - Bugfix: Fixed bit emotes not loading in some rare cases. (#2856)
+23 -3
View File
@@ -5,6 +5,7 @@
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include <QMimeData> #include <QMimeData>
#include <QMimeDatabase>
namespace chatterino { namespace chatterino {
@@ -264,14 +265,33 @@ bool ResizingTextEdit::canInsertFromMimeData(const QMimeData *source) const
void ResizingTextEdit::insertFromMimeData(const QMimeData *source) void ResizingTextEdit::insertFromMimeData(const QMimeData *source)
{ {
if (source->hasImage() || source->hasUrls()) if (source->hasImage())
{ {
this->imagePasted.invoke(source); 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 QCompleter *ResizingTextEdit::getCompleter() const