OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-storage commits / 44c5fcf

Defensive coding around mal-formed JSON
44c5fcfc796ba680b82e1f18eef67b09d65fd9f8
by Linas Vepstas <linasvepstas@gmail.com> · 2026-01-31T17:34:09.000Z

Changed files (1) +12 -0

opencog/persist/json/DecodeJson.cc +12 -0
……@@ -548,6 +548,12 @@ ValuePtr Json::decode_value(const std::string& s,
548548 l++;
549549 r = s.find_first_of(",]", l);
550550 if (std::string::npos == r) break;
551
552 // Bad clients can (and do) send mal-formed JSON.
553 // This includes the empty list [] and expressions
554 // with a trailing comma. Skip out of those.
555 if (r == l) break;
556
551557 std::stringstream ss;
552558 ss << s.substr(l, r-l);
553559 double d;
……@@ -574,6 +580,12 @@ ValuePtr Json::decode_value(const std::string& s,
574580 while (std::string::npos != l)
575581 {
576582 l++;
583
584 // Bad clients can (and do) send mal-formed JSON.
585 // This includes the empty list [] and expressions
586 // with a trailing comma. Skip out of those.
587 if (']' == s[l]) break;
588
577589 std::stringstream ss;
578590 ss << s.substr(l);
579591 std::string uq;