@@ -83,7 +83,8 @@ constexpr std::
83
83
return static_cast <U1>(value);
84
84
}
85
85
86
- static std::string
86
+ // LCOV_EXCL_START
87
+ static inline std::string
87
88
make_name (std::string const & object, std::string const & field)
88
89
{
89
90
if (field.empty ())
@@ -92,90 +93,90 @@ make_name(std::string const& object, std::string const& field)
92
93
return object + " ." + field;
93
94
}
94
95
95
- static Json::Value
96
+ static inline Json::Value
96
97
not_an_object (std::string const & object, std::string const & field)
97
98
{
98
99
return RPC::make_error (
99
100
rpcINVALID_PARAMS,
100
101
" Field '" + make_name (object, field) + " ' is not a JSON object." );
101
102
}
102
103
103
- static Json::Value
104
+ static inline Json::Value
104
105
not_an_object (std::string const & object)
105
106
{
106
107
return not_an_object (object, " " );
107
108
}
108
109
109
- static Json::Value
110
+ static inline Json::Value
110
111
not_an_array (std::string const & object)
111
112
{
112
113
return RPC::make_error (
113
114
rpcINVALID_PARAMS, " Field '" + object + " ' is not a JSON array." );
114
115
}
115
116
116
- static Json::Value
117
+ static inline Json::Value
117
118
unknown_field (std::string const & object, std::string const & field)
118
119
{
119
120
return RPC::make_error (
120
121
rpcINVALID_PARAMS,
121
122
" Field '" + make_name (object, field) + " ' is unknown." );
122
123
}
123
124
124
- static Json::Value
125
+ static inline Json::Value
125
126
out_of_range (std::string const & object, std::string const & field)
126
127
{
127
128
return RPC::make_error (
128
129
rpcINVALID_PARAMS,
129
130
" Field '" + make_name (object, field) + " ' is out of range." );
130
131
}
131
132
132
- static Json::Value
133
+ static inline Json::Value
133
134
bad_type (std::string const & object, std::string const & field)
134
135
{
135
136
return RPC::make_error (
136
137
rpcINVALID_PARAMS,
137
138
" Field '" + make_name (object, field) + " ' has bad type." );
138
139
}
139
140
140
- static Json::Value
141
+ static inline Json::Value
141
142
invalid_data (std::string const & object, std::string const & field)
142
143
{
143
144
return RPC::make_error (
144
145
rpcINVALID_PARAMS,
145
146
" Field '" + make_name (object, field) + " ' has invalid data." );
146
147
}
147
148
148
- static Json::Value
149
+ static inline Json::Value
149
150
invalid_data (std::string const & object)
150
151
{
151
152
return invalid_data (object, " " );
152
153
}
153
154
154
- static Json::Value
155
+ static inline Json::Value
155
156
array_expected (std::string const & object, std::string const & field)
156
157
{
157
158
return RPC::make_error (
158
159
rpcINVALID_PARAMS,
159
160
" Field '" + make_name (object, field) + " ' must be a JSON array." );
160
161
}
161
162
162
- static Json::Value
163
+ static inline Json::Value
163
164
string_expected (std::string const & object, std::string const & field)
164
165
{
165
166
return RPC::make_error (
166
167
rpcINVALID_PARAMS,
167
168
" Field '" + make_name (object, field) + " ' must be a string." );
168
169
}
169
170
170
- static Json::Value
171
+ static inline Json::Value
171
172
too_deep (std::string const & object)
172
173
{
173
174
return RPC::make_error (
174
175
rpcINVALID_PARAMS,
175
176
" Field '" + object + " ' exceeds nesting depth limit." );
176
177
}
177
178
178
- static Json::Value
179
+ static inline Json::Value
179
180
singleton_expected (std::string const & object, unsigned int index)
180
181
{
181
182
return RPC::make_error (
@@ -184,7 +185,7 @@ singleton_expected(std::string const& object, unsigned int index)
184
185
" ]' must be an object with a single key/object value." );
185
186
}
186
187
187
- static Json::Value
188
+ static inline Json::Value
188
189
template_mismatch (SField const & sField )
189
190
{
190
191
return RPC::make_error (
@@ -193,14 +194,15 @@ template_mismatch(SField const& sField)
193
194
" ' contents did not meet requirements for that type." );
194
195
}
195
196
196
- static Json::Value
197
+ static inline Json::Value
197
198
non_object_in_array (std::string const & item, Json::UInt index)
198
199
{
199
200
return RPC::make_error (
200
201
rpcINVALID_PARAMS,
201
202
" Item '" + item + " ' at index " + std::to_string (index) +
202
203
" is not an object. Arrays may only contain objects." );
203
204
}
205
+ // LCOV_EXCL_STOP
204
206
205
207
template <class STResult , class Integer >
206
208
static std::optional<detail::STVar>
@@ -385,10 +387,13 @@ parseLeaf(
385
387
386
388
auto const & field = SField::getField (fieldName);
387
389
390
+ // checked in parseObject
388
391
if (field == sfInvalid)
389
392
{
393
+ // LCOV_EXCL_START
390
394
error = unknown_field (json_name, fieldName);
391
395
return ret;
396
+ // LCOV_EXCL_STOP
392
397
}
393
398
394
399
switch (field.fieldType )
@@ -760,6 +765,12 @@ parseLeaf(
760
765
AccountID uAccount, uIssuer;
761
766
Currency uCurrency;
762
767
768
+ if (!account && !currency && !issuer)
769
+ {
770
+ error = invalid_data (element_name);
771
+ return ret;
772
+ }
773
+
763
774
if (account)
764
775
{
765
776
// human account id
@@ -1153,24 +1164,4 @@ STParsedJSONObject::STParsedJSONObject(
1153
1164
object = parseObject (name, json, sfGeneric, 0 , error);
1154
1165
}
1155
1166
1156
- // ------------------------------------------------------------------------------
1157
-
1158
- STParsedJSONArray::STParsedJSONArray (
1159
- std::string const & name,
1160
- Json::Value const & json)
1161
- {
1162
- using namespace STParsedJSONDetail ;
1163
- auto arr = parseArray (name, json, sfGeneric, 0 , error);
1164
- if (!arr)
1165
- array.reset ();
1166
- else
1167
- {
1168
- auto p = dynamic_cast <STArray*>(&arr->get ());
1169
- if (p == nullptr )
1170
- array.reset ();
1171
- else
1172
- array = std::move (*p);
1173
- }
1174
- }
1175
-
1176
1167
} // namespace ripple
0 commit comments