mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
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:
parent
3977eb74a6
commit
9fb5ef60d4
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue