aboutsummaryrefslogtreecommitdiffstats
path: root/include/qpdf/JSON.hh
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-20 15:57:30 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-20 16:13:15 +0200
commit3eb77a700434ed6d9b51e326fa4d49c530fcd473 (patch)
tree3f2c1a19093f25b8f849100dfb512038f2fa0db5 /include/qpdf/JSON.hh
parent6d4e3ba8a43d8a084a94f9cea4669cb35812fb67 (diff)
downloadqpdf-3eb77a700434ed6d9b51e326fa4d49c530fcd473.tar.zst
JSON: detect duplicate dictionary keys while parsing
Diffstat (limited to 'include/qpdf/JSON.hh')
-rw-r--r--include/qpdf/JSON.hh10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/qpdf/JSON.hh b/include/qpdf/JSON.hh
index e711a2df..e6857ca6 100644
--- a/include/qpdf/JSON.hh
+++ b/include/qpdf/JSON.hh
@@ -42,6 +42,7 @@
#include <list>
#include <map>
#include <memory>
+#include <set>
#include <string>
#include <vector>
@@ -149,6 +150,14 @@ class JSON
QPDF_DLL
bool isDictionary() const;
+ // If the key is already in the dictionary, return true.
+ // Otherwise, mark it has seen and return false. This is primarily
+ // intended to used by the parser to detect duplicate keys when
+ // the reactor blocks them from being added to the final
+ // dictionary.
+ QPDF_DLL
+ bool checkDictionaryKeySeen(std::string const& key);
+
// Accessors. Accessor behavior:
//
// - If argument is wrong type, including null, return false
@@ -314,6 +323,7 @@ class JSON
virtual ~JSON_dictionary() = default;
virtual void write(Pipeline*, size_t depth) const;
std::map<std::string, std::shared_ptr<JSON_value>> members;
+ std::set<std::string> parsed_keys;
};
struct JSON_array: public JSON_value
{