summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/localtemp.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/localtemp.cpp b/src/localtemp.cpp
index a1b212e..3a64200 100644
--- a/src/localtemp.cpp
+++ b/src/localtemp.cpp
@@ -316,6 +316,42 @@ bool localtemp::getInfo()
string fullkey=yyyymmdd+hhmmss;
size_t blockpos=http->data.find("\""+fullkey+"\":");
+
+ string selected_key;
+ for (size_t pos = 0; pos + 16 < http->data.size(); ++pos) {
+ if (http->data[pos] != '"')
+ continue;
+
+ string candidate = http->data.substr(pos + 1, 14);
+
+ bool digits = true;
+ for (size_t i = 0; i < candidate.size(); ++i) {
+ if (candidate[i] < '0' || candidate[i] > '9') {
+ digits = false;
+ break;
+ }
+ }
+
+ if (!digits || http->data[pos + 15] != '"')
+ continue;
+
+ size_t colon = http->data.find(':', pos + 16);
+ if (colon == string::npos)
+ continue;
+
+ size_t object_start =
+ http->data.find_first_not_of(" \t\r\n", colon + 1);
+
+ if (object_start == string::npos ||
+ http->data[object_start] != '{')
+ continue;
+
+ if (candidate <= fullkey &&
+ (selected_key.empty() || candidate > selected_key)) {
+ selected_key = candidate;
+ blockpos = pos;
+ }
+ }
if (blockpos==string::npos)
{