Prevent usage with Gab domains.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2019-06-26 02:35:35 +02:00
parent f293d54a63
commit 9b0c68f2bf
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 19 additions and 1 deletions

View File

@ -22,6 +22,7 @@
#include <iostream>
#include <algorithm>
#include <fstream>
#include <exception>
#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()
{}