Skip to content

Commit

Permalink
Fix Handling of FFZ CDN URLs with https already appended (#4432)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsge authored Mar 5, 2023
1 parent 1dc2bcc commit b9e87dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Minor: Delete all but the last 5 crashdumps on application start. (#4392)
- Minor: Added `/banid` command that allows banning by user ID. (#4411)
- Bugfix: Fixed FrankerFaceZ emotes/badges not loading due to API change. (#4432)
- Bugfix: Fixed uploaded AppImage not being able most web requests. (#4400)
- Bugfix: Fixed a potential race condition due to using the wrong lock when loading 7TV badges. (#4402)
- Dev: Add capability to build Chatterino with Qt6. (#4393)
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ set(SOURCE_FILES
providers/ffz/FfzBadges.hpp
providers/ffz/FfzEmotes.cpp
providers/ffz/FfzEmotes.hpp
providers/ffz/FfzUtil.cpp
providers/ffz/FfzUtil.hpp

providers/irc/AbstractIrcServer.cpp
providers/irc/AbstractIrcServer.hpp
Expand Down
15 changes: 7 additions & 8 deletions src/providers/ffz/FfzBadges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "common/NetworkResult.hpp"
#include "common/Outcome.hpp"
#include "messages/Emote.hpp"
#include "providers/ffz/FfzUtil.hpp"

#include <QJsonArray>
#include <QJsonObject>
Expand Down Expand Up @@ -67,14 +68,12 @@ void FfzBadges::load()
auto jsonBadge = jsonBadge_.toObject();
auto jsonUrls = jsonBadge.value("urls").toObject();

auto emote = Emote{
EmoteName{},
ImageSet{
Url{QString("https:") + jsonUrls.value("1").toString()},
Url{QString("https:") + jsonUrls.value("2").toString()},
Url{QString("https:") +
jsonUrls.value("4").toString()}},
Tooltip{jsonBadge.value("title").toString()}, Url{}};
auto emote =
Emote{EmoteName{},
ImageSet{parseFfzUrl(jsonUrls.value("1").toString()),
parseFfzUrl(jsonUrls.value("2").toString()),
parseFfzUrl(jsonUrls.value("4").toString())},
Tooltip{jsonBadge.value("title").toString()}, Url{}};

Badge badge;

Expand Down
4 changes: 3 additions & 1 deletion src/providers/ffz/FfzEmotes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "messages/Emote.hpp"
#include "messages/Image.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/ffz/FfzUtil.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "singletons/Settings.hpp"

Expand All @@ -26,8 +27,9 @@ namespace {

assert(emote.isString());

return {"https:" + emote.toString()};
return parseFfzUrl(emote.toString());
}

void fillInEmoteData(const QJsonObject &urls, const EmoteName &name,
const QString &tooltip, Emote &emoteData)
{
Expand Down
12 changes: 12 additions & 0 deletions src/providers/ffz/FfzUtil.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "providers/ffz/FfzUtil.hpp"

namespace chatterino {

Url parseFfzUrl(const QString &ffzUrl)
{
QUrl asURL(ffzUrl);
asURL.setScheme("https");
return {asURL.toString()};
}

} // namespace chatterino
12 changes: 12 additions & 0 deletions src/providers/ffz/FfzUtil.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "common/Aliases.hpp"

#include <QString>
#include <QUrl>

namespace chatterino {

Url parseFfzUrl(const QString &ffzUrl);

} // namespace chatterino

0 comments on commit b9e87dc

Please sign in to comment.