forked from tastytea/libravatarserv
Bugfix: Return 404 if fallback is empty or unknown
This commit is contained in:
parent
50d902bcc9
commit
8cc6e73cb1
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required (VERSION 3.2)
|
||||
project(libravatarserv
|
||||
VERSION 0.4.2
|
||||
VERSION 0.4.3
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
|
|
|
@ -62,33 +62,31 @@ int main()
|
|||
else
|
||||
{
|
||||
cerr << "Error " << std::to_string(image.error) << ": Could not open file.\n";
|
||||
if (avatar.fallback.empty() || avatar.fallback == "404")
|
||||
if (avatar.fallback.substr(0, 4) == "http")
|
||||
{
|
||||
cout << "Status: 404 Not Found\n\n";
|
||||
cout << "Status: 307 Temporary Redirect\n";
|
||||
cout << "Location: " << avatar.fallback << endl << endl;
|
||||
}
|
||||
else if (avatar.fallback.substr(0, 2) == "mp" ||
|
||||
avatar.fallback.substr(0, 2) == "mm")
|
||||
{
|
||||
// MD5 hash of 'mp'
|
||||
image = image::get("1f2dfa567dcf95833eddf7aec167fec7",
|
||||
avatar.size);
|
||||
if (image.error == 0)
|
||||
{
|
||||
image::write(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Status: 404 Not Found\n\n";
|
||||
cerr << "Mystery person not found.\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (avatar.fallback.substr(0, 4) == "http")
|
||||
{
|
||||
cout << "Status: 307 Temporary Redirect\n";
|
||||
cout << "Location: " << avatar.fallback << endl << endl;
|
||||
}
|
||||
else if (avatar.fallback.substr(0, 2) == "mp" ||
|
||||
avatar.fallback.substr(0, 2) == "mm")
|
||||
{
|
||||
// MD5 hash of 'mp'
|
||||
image = image::get("1f2dfa567dcf95833eddf7aec167fec7",
|
||||
avatar.size);
|
||||
if (image.error == 0)
|
||||
{
|
||||
image::write(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Status: 404 Not Found\n\n";
|
||||
cerr << "Mystery person not found.\n";
|
||||
}
|
||||
}
|
||||
// If fallback is empty or unknown
|
||||
cout << "Status: 404 Not Found\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user