diff --git a/src/mastodon-cpp.cpp b/src/mastodon-cpp.cpp index bf042a9..a047ad6 100644 --- a/src/mastodon-cpp.cpp +++ b/src/mastodon-cpp.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "version.hpp" #include "debug.hpp" #include "mastodon-cpp.hpp" @@ -36,7 +37,24 @@ API::API(const string &instance, const string &access_token) , _exceptions(false) , _proxy("") , _proxy_userpw("") -{} +{ + bool fash = false; + const std::regex re_gab("(?:\\.|^)gab\\.[^\\.]+$"); + + for (const std::regex &re : { re_gab }) + { + if (std::regex_search(_instance, re)) + { + fash = true; + break; + } + } + + if (fash) + { + throw std::runtime_error("Fascist instance detected: " + _instance); + } +} API::~API() {}