From d2d35d8ac586beeb6ec741567488925cb045efd1 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 9 Dec 2018 19:54:38 +0100 Subject: [PATCH] If requested size is < 0, return 80px image. --- src/http.cpp | 8 ++++---- src/libravatarserv.hpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 79eb711..1bbf852 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -39,7 +39,7 @@ const Request http::parse_request(const string &request) std::exit(1); } - uint16_t size = 80; + int16_t size = 80; string fallback; string digest = request.substr(8); std::transform(digest.begin(), digest.end(), digest.begin(), ::tolower); @@ -54,7 +54,7 @@ const Request http::parse_request(const string &request) { try { - size = static_cast(std::stoul(answer)); + size = static_cast(std::stoul(answer)); } catch (const std::exception &) {} } else @@ -64,7 +64,7 @@ const Request http::parse_request(const string &request) { try { - size = static_cast(std::stoul(answer)); + size = static_cast(std::stoul(answer)); } catch (const std::exception &) {} } } @@ -72,7 +72,7 @@ const Request http::parse_request(const string &request) { size = 512; } - if (size == 0) + else if (size <= 0) { size = 80; } diff --git a/src/libravatarserv.hpp b/src/libravatarserv.hpp index 7f78e6c..5352dae 100644 --- a/src/libravatarserv.hpp +++ b/src/libravatarserv.hpp @@ -34,6 +34,7 @@ using std::string; using std::uint16_t; using std::uint8_t; +using std::int8_t; int main(); @@ -56,7 +57,7 @@ namespace http // http.cpp struct Request { const string digest; - const uint16_t size; + const int16_t size; string fallback; };