From 0dc5c0c015aada7650398fbca7c87533ac0cd7b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Bo=C3=ABs?= Date: Tue, 8 Oct 2024 22:13:01 +0200 Subject: [PATCH] Fixing URL encoding issues --- CHANGELOG.md | 4 ++++ src/WettergeraetDesktop/Frame.cpp | 17 ++++++----------- src/WettergeraetLib/Argumentor.cpp | 2 +- src/WettergeraetLib/FetchUrl.cpp | 5 +++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80fde95..e168cde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change log +## 1.7.4 + +- 💊 Fixing URL encoding issues + ## 1.7.3 - 🎁 Improve menu structure, adding "Reset time & date" diff --git a/src/WettergeraetDesktop/Frame.cpp b/src/WettergeraetDesktop/Frame.cpp index a23ee56..a306a54 100644 --- a/src/WettergeraetDesktop/Frame.cpp +++ b/src/WettergeraetDesktop/Frame.cpp @@ -456,17 +456,12 @@ void Frame::actionFetch(wxCommandEvent& WXUNUSED(event)) return; } - auto date = this->utcDateInput->GetValue().FormatISODate().mb_str().data(); - auto time = this->utcTimeInput->GetValue().FormatISOTime().mb_str().data(); - - // yyyy-mm-ddThh:mm:ssZ - char searchDate[25]; - sprintf( - searchDate, - "%sT%sZ", - date, - time - ); + auto searchDate = this->utcDateInput->GetValue().FormatISODate().ToStdString() + .append("T") + .append( + this->utcTimeInput->GetValue().FormatISOTime().ToStdString() + ) + .append("Z"); this->metarInput->SetValue("Loading..."); FetchUrl urlFetcher; diff --git a/src/WettergeraetLib/Argumentor.cpp b/src/WettergeraetLib/Argumentor.cpp index 338ffd3..1ed6c17 100644 --- a/src/WettergeraetLib/Argumentor.cpp +++ b/src/WettergeraetLib/Argumentor.cpp @@ -3,7 +3,7 @@ #include #include -const char* Argumentor::APP_VERSION = "1.7.3"; +const char* Argumentor::APP_VERSION = "1.7.4"; #if _WIN64 const char* Argumentor::APP_TARGET = "64-bit"; #else diff --git a/src/WettergeraetLib/FetchUrl.cpp b/src/WettergeraetLib/FetchUrl.cpp index a0ba29e..46344f5 100644 --- a/src/WettergeraetLib/FetchUrl.cpp +++ b/src/WettergeraetLib/FetchUrl.cpp @@ -106,7 +106,7 @@ std::string FetchUrl::fetch(std::string url, unsigned short fetchMode, std::stri throw std::invalid_argument("Timeout for " + url); } else if (res != CURLE_OK) { - throw std::invalid_argument(curl_easy_strerror(res)); + throw std::invalid_argument(std::string(curl_easy_strerror(res)) + ": " + url); } if (fetchMode == FetchUrl::MODE_JSON) { @@ -129,10 +129,11 @@ std::string FetchUrl::fetch(std::string url, std::string icaoCode, std::string d std::regex("[^a-zA-z0-9]"), "" ); + date = std::regex_replace( date, std::regex(":"), - std::string("%3A") + std::string("%%3A") ); if (lowercase) { transform(icaoCode.begin(), icaoCode.end(), icaoCode.begin(), ::tolower);