include/oa_validate.h

filter: Statementstmt 97.6% 589 / 603 Branchbran 72.5% 569 / 784 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 83.4% 1158 / 1387 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« include/oa_tools.h ↑ Summary include/oa_types.h »
1 #ifndef OA_VALIDATE_H
2 #define OA_VALIDATE_H
3  
4 /* Per-request validation for a matched operation: percent-decode path
5 * captures, parse the query string and Cookie header in C, JSON-decode the
6 * body, run every declared parameter and the body through the JSF ABI, and
7 * assemble the validated params structure. Two modes: errs == NULL uses the
8 * cheap boolean path (is_valid); with an AV, all failures are collected as
9 * hashrefs - JSF's error hashes augmented with `in` and `name`. */
10  
11 /* ---- decoding helpers ------------------------------------------------------ */
12  
13 52 static int oa_hexval(char c) {
14 52 ▶ if (c >= '0' && c <= '9') return c - '0';
Branch: 2 branches
BranchTrueFalseTotal
if (c >= '0' && c <= '9') return c - '0'; 52 0 52
if (c >= '0' && c <= '9') return c - '0'; 39 13 52
15 13 ▶ if (c >= 'a' && c <= 'f') return c - 'a' + 10;
Branch: 2 branches
BranchTrueFalseTotal
if (c >= 'a' && c <= 'f') return c - 'a' + 10; 0 13 13
if (c >= 'a' && c <= 'f') return c - 'a' + 10; 0 0 0
16 13 ▶ if (c >= 'A' && c <= 'F') return c - 'A' + 10;
Branch: 2 branches
BranchTrueFalseTotal
if (c >= 'A' && c <= 'F') return c - 'A' + 10; 13 0 13
if (c >= 'A' && c <= 'F') return c - 'A' + 10; 13 0 13
17 0 return -1;
18 }
19  
20 /* %XX (and optionally '+' -> space) decode into a fresh SV */
21 3553 static SV *oa_pct_decode(pTHX_ const char *p, STRLEN l, int plus) {
22 3553 SV *out = newSV(l + 1);
23 char *d;
24 3553 STRLEN i, o = 0;
25 3553 SvPOK_on(out);
26 3553 d = SvPVX(out);
27 13515 ▶ for (i = 0; i < l; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < l; i++) { 9962 3553 13515
28 9962 ▶ if (p[i] == '%' && i + 2 < l) {
Branch: 2 branches
BranchTrueFalseTotal
if (p[i] == '%' && i + 2 < l) { 26 9936 9962
if (p[i] == '%' && i + 2 < l) { 26 0 26
29 26 int h = oa_hexval(p[i + 1]), lo = oa_hexval(p[i + 2]);
30 26 ▶ if (h >= 0 && lo >= 0) { d[o++] = (char)((h << 4) | lo); i += 2; continue; }
Branch: 2 branches
BranchTrueFalseTotal
if (h >= 0 && lo >= 0) { d[o++] = (char)((h << 4) | lo); i += 2; continue; } 26 0 26
if (h >= 0 && lo >= 0) { d[o++] = (char)((h << 4) | lo); i += 2; continue; } 26 0 26
31 }
32 9936 ▶ if (plus && p[i] == '+') { d[o++] = ' '; continue; }
Branch: 2 branches
BranchTrueFalseTotal
if (plus && p[i] == '+') { d[o++] = ' '; continue; } 7336 2600 9936
if (plus && p[i] == '+') { d[o++] = ' '; continue; } 2 7334 7336
33 9934 d[o++] = p[i];
34 }
35 3553 d[o] = '\0';
36 3553 SvCUR_set(out, o);
37 3553 return out;
38 }
39  
40 /* ---- parameter serialization (style / explode) ------------------------------
41 *
42 * Split `l` bytes on `delim` into a fresh AV. `decode` percent-decodes each
43 * piece AFTER the split, which is the only correct order: %2C is a comma that
44 * belongs to the value, not a delimiter, so decoding first would split
45 * `a%2Cb` into two elements.
46 *
47 * Header and cookie values are NOT decoded here. Header values never were,
48 * and oa_parse_cookies deliberately keeps its values raw; decoding them now
49 * would quietly change what every existing document sees. */
50 54 static SV *oa_split(pTHX_ const char *p, STRLEN l, char delim,
51 int decode, int plus) {
52 54 AV *av = newAV();
53 54 STRLEN s = 0;
54 112 for (;;) {
55 166 STRLEN e = s;
56 682 ▶ while (e < l && p[e] != delim) e++;
Branch: 2 branches
BranchTrueFalseTotal
while (e < l && p[e] != delim) e++; 628 54 682
while (e < l && p[e] != delim) e++; 516 112 628
57 166 ▶ av_push(av, decode ? oa_pct_decode(aTHX_ p + s, e - s, plus)
Branch: 1 branch
BranchTrueFalseTotal
av_push(av, decode ? oa_pct_decode(aTHX_ p + s, e - s, plus) 140 26 166
58 : newSVpvn(p + s, e - s));
59 166 ▶ if (e >= l) break;
Branch: 1 branch
BranchTrueFalseTotal
if (e >= l) break; 54 112 166
60 112 s = e + 1;
61 }
62 54 return newRV_noinc((SV *)av);
63 }
64  
65 /* Split on any of `toks`, matched against the RAW text, decoding each piece
66 * after. This exists beside oa_split because a comma and a space are not
67 * symmetrical: `%2C` is an ESCAPED comma that belongs inside its element,
68 * while a space can only reach us as `%20` or `+`, so for spaceDelimited
69 * those encoded spellings ARE the delimiter. The spec offers no way to put a
70 * literal space inside a spaceDelimited array, so none is invented here. */
71 14 static SV *oa_split_tokens(pTHX_ const char *p, STRLEN l,
72 const char *const *toks, int plus) {
73 14 AV *av = newAV();
74 14 STRLEN s = 0;
75 34 for (;;) {
76 48 STRLEN e = s;
77 48 STRLEN tl = 0;
78 164 ▶ while (e < l) {
Branch: 1 branch
BranchTrueFalseTotal
while (e < l) { 150 14 164
79 int t;
80 529 ▶ for (t = 0; toks[t]; t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = 0; toks[t]; t++) { 413 116 529
81 413 STRLEN len = (STRLEN)strlen(toks[t]);
82 413 ▶ if (e + len <= l && memEQ(p + e, toks[t], len)) { tl = len; break; }
Branch: 2 branches
BranchTrueFalseTotal
if (e + len <= l && memEQ(p + e, toks[t], len)) { tl = len; break; } 377 36 413
if (e + len <= l && memEQ(p + e, toks[t], len)) { tl = len; break; } 34 343 377
83 }
84 150 ▶ if (tl) break;
Branch: 1 branch
BranchTrueFalseTotal
if (tl) break; 34 116 150
85 116 e++;
86 }
87 48 av_push(av, oa_pct_decode(aTHX_ p + s, e - s, plus));
88 48 ▶ if (e >= l) break;
Branch: 1 branch
BranchTrueFalseTotal
if (e >= l) break; 14 34 48
89 34 s = e + tl;
90 }
91 14 return newRV_noinc((SV *)av);
92 }
93  
94 /* ---- object-typed parameters ------------------------------------------------
95 *
96 * Every style in the specification's Style Examples table can carry an object,
97 * not just deepObject. Two shapes reach here, and which one depends only on
98 * `explode`:
99 *
100 * not exploded R,100,G,200,B,150 a flat list, read as key,value pairs
101 * exploded R=100.G=200.B=150 each piece is its own `key=value`
102 *
103 * The delimiter differs per style but the assembly does not, so both take an
104 * already-split list. An odd trailing element in the pair form, or a piece with
105 * no `=` in the exploded form, is skipped rather than guessed at: the schema
106 * refuses the result afterwards, which is a better error than an invented one.
107 */
108 13 static SV *oa_obj_from_pairs(pTHX_ SV *listrv) {
109 13 AV *av = (AV *)SvRV(listrv);
110 13 HV *h = newHV();
111 13 SSize_t i, n = av_len(av) + 1;
112 52 ▶ for (i = 0; i + 1 < n; i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i + 1 < n; i += 2) { 39 13 52
113 39 SV **k = av_fetch(av, i, 0);
114 39 SV **v = av_fetch(av, i + 1, 0);
115 39 ▶ if (k && *k && v && *v) {
Branch: 4 branches
BranchTrueFalseTotal
if (k && *k && v && *v) { 39 0 39
if (k && *k && v && *v) { 39 0 39
if (k && *k && v && *v) { 39 0 39
if (k && *k && v && *v) { 39 0 39
116 39 STRLEN kl; const char *kp = SvPV_const(*k, kl);
117 39 ▶ if (kl) (void)hv_store(h, kp, (I32)kl, newSVsv(*v), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (kl) (void)hv_store(h, kp, (I32)kl, newSVsv(*v), 0); 39 0 39
118 }
119 }
120 13 return sv_2mortal(newRV_noinc((SV *)h));
121 }
122  
123 7 static SV *oa_obj_from_kv(pTHX_ SV *listrv) {
124 7 AV *av = (AV *)SvRV(listrv);
125 7 HV *h = newHV();
126 7 SSize_t i, n = av_len(av) + 1;
127 28 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 21 7 28
128 21 SV **e = av_fetch(av, i, 0);
129 STRLEN el; const char *ep, *eq;
130 21 ▶ if (!e || !*e) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (!e || !*e) continue; 21 0 21
if (!e || !*e) continue; 0 21 21
131 21 ep = SvPV_const(*e, el);
132 21 eq = (const char *)memchr(ep, '=', el);
133 21 ▶ if (!eq || eq == ep) continue; /* no key, or no `=`: skip */
Branch: 2 branches
BranchTrueFalseTotal
if (!eq || eq == ep) continue; /* no key, or no `=`: skip */ 21 0 21
if (!eq || eq == ep) continue; /* no key, or no `=`: skip */ 0 21 21
134 21 (void)hv_store(h, ep, (I32)(eq - ep),
135 newSVpvn(eq + 1, el - (STRLEN)(eq - ep) - 1), 0);
136 }
137 7 return sv_2mortal(newRV_noinc((SV *)h));
138 }
139  
140 /* A path parameter, per its style. The style's marker is stripped whether or
141 * not the schema wants a list - `label` on a scalar is `.5` and `matrix` is
142 * `;id=5`, so handling the marker only for arrays would leave scalars holding
143 * it. Returns a mortal: a decoded scalar, or an arrayref of decoded pieces. */
144 2208 static SV *oa_style_path(pTHX_ oa_param *pp, const char *vp, STRLEN vl) {
145 2208 char delim = ',';
146 2208 STRLEN nl = 0;
147 2208 const char *np = NULL;
148  
149 2208 ▶ if (pp->style == OA_ST_LABEL) {
Branch: 1 branch
BranchTrueFalseTotal
if (pp->style == OA_ST_LABEL) { 18 2190 2208
150 18 ▶ if (vl && vp[0] == '.') { vp++; vl--; }
Branch: 2 branches
BranchTrueFalseTotal
if (vl && vp[0] == '.') { vp++; vl--; } 18 0 18
if (vl && vp[0] == '.') { vp++; vl--; } 18 0 18
151 18 ▶ if (pp->explode) delim = '.';
Branch: 1 branch
BranchTrueFalseTotal
if (pp->explode) delim = '.'; 9 9 18
152 }
153 2190 ▶ else if (pp->style == OA_ST_MATRIX) {
Branch: 1 branch
BranchTrueFalseTotal
else if (pp->style == OA_ST_MATRIX) { 18 2172 2190
154 18 np = SvPV_const(pp->name, nl);
155 18 ▶ if (vl && vp[0] == ';') { vp++; vl--; }
Branch: 2 branches
BranchTrueFalseTotal
if (vl && vp[0] == ';') { vp++; vl--; } 18 0 18
if (vl && vp[0] == ';') { vp++; vl--; } 18 0 18
156 18 ▶ if (pp->explode) delim = ';';
Branch: 1 branch
BranchTrueFalseTotal
if (pp->explode) delim = ';'; 9 9 18
157 /* a leading `name=` is the style speaking, not the value */
158 18 ▶ if (vl > nl && memEQ(vp, np, nl) && vp[nl] == '=') {
Branch: 3 branches
BranchTrueFalseTotal
if (vl > nl && memEQ(vp, np, nl) && vp[nl] == '=') { 16 2 18
if (vl > nl && memEQ(vp, np, nl) && vp[nl] == '=') { 14 2 16
if (vl > nl && memEQ(vp, np, nl) && vp[nl] == '=') { 14 0 14
159 14 vp += nl + 1; vl -= nl + 1;
160 }
161 /* `;color` with nothing after it is the EMPTY value, not the literal
162 * string "color" - the name is the style speaking here too, and with
163 * no `=` the strip above does not fire */
164 4 ▶ else if (vl == nl && memEQ(vp, np, nl)) {
Branch: 2 branches
BranchTrueFalseTotal
else if (vl == nl && memEQ(vp, np, nl)) { 2 2 4
else if (vl == nl && memEQ(vp, np, nl)) { 2 0 2
165 2 vp += nl; vl = 0;
166 }
167 }
168  
169 /* An object is assembled from the same pieces an array would be, so the
170 * split is shared - only what is built from it differs. Exploded matrix is
171 * the one shape whose pieces still carry the parameter name, and for an
172 * object they do not: `;R=100;G=200` names the MEMBERS, so the name strip
173 * below is an array-only concern. */
174 2208 ▶ if (pp->is_object && !pp->is_array) {
Branch: 2 branches
BranchTrueFalseTotal
if (pp->is_object && !pp->is_array) { 12 2196 2208
if (pp->is_object && !pp->is_array) { 12 0 12
175 12 SV *rv = sv_2mortal(oa_split(aTHX_ vp, vl, delim, 1, 0));
176 6 return pp->explode ? oa_obj_from_kv(aTHX_ rv)
177 18 ▶ : oa_obj_from_pairs(aTHX_ rv);
Branch: 1 branch
BranchTrueFalseTotal
: oa_obj_from_pairs(aTHX_ rv); 6 6 12
178 }
179  
180 2196 ▶ if (!pp->is_array)
Branch: 1 branch
BranchTrueFalseTotal
if (!pp->is_array) 2176 20 2196
181 2176 return sv_2mortal(oa_pct_decode(aTHX_ vp, vl, 0));
182  
183 {
184 20 SV *rv = sv_2mortal(oa_split(aTHX_ vp, vl, delim, 1, 0));
185 /* exploded matrix repeats the name: `;id=a;id=b` */
186 20 ▶ if (pp->style == OA_ST_MATRIX && pp->explode && np) {
Branch: 3 branches
BranchTrueFalseTotal
if (pp->style == OA_ST_MATRIX && pp->explode && np) { 7 13 20
if (pp->style == OA_ST_MATRIX && pp->explode && np) { 4 3 7
if (pp->style == OA_ST_MATRIX && pp->explode && np) { 4 0 4
187 4 AV *av = (AV *)SvRV(rv);
188 4 SSize_t i, n = av_len(av) + 1;
189 14 ▶ for (i = 0; i < n; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < n; i++) { 10 4 14
190 10 SV **e = av_fetch(av, i, 0);
191 10 ▶ if (e && *e) {
Branch: 2 branches
BranchTrueFalseTotal
if (e && *e) { 10 0 10
if (e && *e) { 10 0 10
192 10 STRLEN el; const char *ep = SvPV_const(*e, el);
193 10 ▶ if (el > nl && memEQ(ep, np, nl) && ep[nl] == '=')
Branch: 3 branches
BranchTrueFalseTotal
if (el > nl && memEQ(ep, np, nl) && ep[nl] == '=') 6 4 10
if (el > nl && memEQ(ep, np, nl) && ep[nl] == '=') 6 0 6
if (el > nl && memEQ(ep, np, nl) && ep[nl] == '=') 6 0 6
194 6 sv_setpvn(*e, ep + nl + 1, el - nl - 1);
195 }
196 }
197 }
198 20 return rv;
199 }
200 }
201  
202 /* ---- error helpers --------------------------------------------------------- */
203  
204 11 static const char *oa_loc_name(int loc) {
205 static const char *n[OA_IN_N] = { "path", "query", "header", "cookie" };
206 11 return n[loc];
207 }
208  
209 25 static void oa_err_push(pTHX_ AV *errs, const char *in, SV *name,
210 const char *keyword, const char *msg) {
211 25 HV *e = newHV();
212 25 (void)hv_stores(e, "in", newSVpv(in, 0));
213 25 ▶ if (name) (void)hv_stores(e, "name", newSVsv(name));
Branch: 1 branch
BranchTrueFalseTotal
if (name) (void)hv_stores(e, "name", newSVsv(name)); 17 8 25
214 25 (void)hv_stores(e, "keyword", newSVpv(keyword, 0));
215 25 (void)hv_stores(e, "message", newSVpv(msg, 0));
216 25 av_push(errs, newRV_noinc((SV *)e));
217 25 }
218  
219 /* run one value through a handle; on failure augment the new JSF errors */
220 4773 static int oa_check(pTHX_ SV *handle, SV *value, AV *errs,
221 const char *in, SV *name) {
222 4773 ▶ if (!handle) return 1; /* no schema: anything goes */
Branch: 1 branch
BranchTrueFalseTotal
if (!handle) return 1; /* no schema: anything goes */ 0 4773 4773
223 4773 ▶ if (!errs) return JSF->is_valid(aTHX_ handle, value);
Branch: 1 branch
BranchTrueFalseTotal
if (!errs) return JSF->is_valid(aTHX_ handle, value); 0 4773 4773
224 {
225 4773 SSize_t before = av_len(errs);
226 4773 int ok = JSF->validate(aTHX_ handle, value, errs);
227 4773 ▶ if (!ok) {
Branch: 1 branch
BranchTrueFalseTotal
if (!ok) { 1272 3501 4773
228 1272 SSize_t i, after = av_len(errs);
229 2677 ▶ for (i = before + 1; i <= after; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = before + 1; i <= after; i++) { 1405 1272 2677
230 1405 SV **e = av_fetch(errs, i, 0);
231 1405 ▶ HV *h = (e && *e && SvROK(*e)) ? (HV *)SvRV(*e) : NULL;
Branch: 3 branches
BranchTrueFalseTotal
HV *h = (e && *e && SvROK(*e)) ? (HV *)SvRV(*e) : NULL; 1405 0 1405
HV *h = (e && *e && SvROK(*e)) ? (HV *)SvRV(*e) : NULL; 1405 0 1405
HV *h = (e && *e && SvROK(*e)) ? (HV *)SvRV(*e) : NULL; 1405 0 1405
232 1405 ▶ if (h) {
Branch: 1 branch
BranchTrueFalseTotal
if (h) { 1405 0 1405
233 1405 (void)hv_stores(h, "in", newSVpv(in, 0));
234 1405 ▶ if (name) (void)hv_stores(h, "name", newSVsv(name));
Branch: 1 branch
BranchTrueFalseTotal
if (name) (void)hv_stores(h, "name", newSVsv(name)); 524 881 1405
235 }
236 }
237 }
238 4773 return ok;
239 }
240 }
241  
242 static SV *oa_body_decode(pTHX_ SV *text); /* defined below */
243  
244 /* One declared parameter against its value.
245 *
246 * The ordinary case is a straight schema check. A parameter declared with
247 * `content` rather than `schema` carries a document of that media type in a
248 * single value - `?filter={"a":1}` - so the value is decoded first and the
249 * schema then sees the structure it was written about. An undecodable value is
250 * a 400 rather than a silent pass, exactly as a request body is; a media type
251 * with no decoder is left alone, as an undeclared body type is. */
252 2827 static int oa_check_param(pTHX_ oa_param *pp, SV *value, AV *errs,
253 const char *in) {
254 2827 SV *data = value;
255 2827 ▶ if (!pp->handle) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (!pp->handle) return 1; 1 2826 2827
256 2826 ▶ if (pp->ctype) {
Branch: 1 branch
BranchTrueFalseTotal
if (pp->ctype) { 524 2302 2826
257 524 STRLEN cl; const char *cp = SvPV_const(pp->ctype, cl);
258 525 ▶ if (!oa_ctype_is_json(cp, cl)) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_ctype_is_json(cp, cl)) return 1; 0 524 524
259 524 ▶ if (!SvROK(value)) {
Branch: 1 branch
BranchTrueFalseTotal
if (!SvROK(value)) { 524 0 524
260 524 data = oa_body_decode(aTHX_ value);
261 524 ▶ if (!data) {
Branch: 1 branch
BranchTrueFalseTotal
if (!data) { 1 523 524
262 1 ▶ if (errs) oa_err_push(aTHX_ errs, in, pp->name, "content",
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, in, pp->name, "content", 1 0 1
263 "parameter is not valid JSON");
264 1 return 0;
265 }
266 }
267 }
268 2825 return oa_check(aTHX_ pp->handle, data, errs, in, pp->name);
269 }
270  
271 /* ---- query / cookie parsing ------------------------------------------------ */
272  
273 /* Parse a query string into a fresh HV: every key decoded; a key is an
274 * arrayref when the op declares that query parameter as array-typed (repeat
275 * keys accumulate), else last value wins. Undeclared keys are kept (string). */
276 1166 static HV *oa_parse_query(pTHX_ oa_op *o, const char *qs, STRLEN ql) {
277 /* a space reaches us only encoded, so both spellings are the delimiter */
278 static const char *const tok_space[] = { "%20", "+", " ", NULL };
279 static const char *const tok_pipe[] = { "%7C", "%7c", "|", NULL };
280 1166 HV *out = newHV();
281 1166 STRLEN s = 0;
282 1754 ▶ while (s < ql) {
Branch: 1 branch
BranchTrueFalseTotal
while (s < ql) { 588 1166 1754
283 588 STRLEN e = s, eq;
284 SV *k, *v;
285 int i;
286 588 oa_param *pp = NULL;
287 const char *rawv;
288 STRLEN rawvl;
289  
290 8560 ▶ while (e < ql && qs[e] != '&') e++;
Branch: 2 branches
BranchTrueFalseTotal
while (e < ql && qs[e] != '&') e++; 7993 567 8560
while (e < ql && qs[e] != '&') e++; 7972 21 7993
291 588 eq = s;
292 3916 ▶ while (eq < e && qs[eq] != '=') eq++;
Branch: 2 branches
BranchTrueFalseTotal
while (eq < e && qs[eq] != '=') eq++; 3916 0 3916
while (eq < e && qs[eq] != '=') eq++; 3328 588 3916
293 588 ▶ if (eq > s) {
Branch: 1 branch
BranchTrueFalseTotal
if (eq > s) { 588 0 588
294 588 k = sv_2mortal(oa_pct_decode(aTHX_ qs + s, eq - s, 1));
295 /* the RAW value: the declared parameter is found first, because
296 * a style has to split before anything is decoded */
297 588 ▶ rawv = qs + (eq < e ? eq + 1 : e);
Branch: 1 branch
BranchTrueFalseTotal
rawv = qs + (eq < e ? eq + 1 : e); 588 0 588
298 588 ▶ rawvl = eq < e ? e - eq - 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
rawvl = eq < e ? e - eq - 1 : 0; 588 0 588
299  
300 625 ▶ for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) { 604 21 625
301 604 ▶ if (sv_eq(o->params[OA_IN_QUERY][i].name, k)) {
Branch: 1 branch
BranchTrueFalseTotal
if (sv_eq(o->params[OA_IN_QUERY][i].name, k)) { 567 37 604
302 567 pp = &o->params[OA_IN_QUERY][i];
303 567 break;
304 }
305 }
306  
307 /* deepObject: `v[k]=x` is a MEMBER of the parameter named `v`, so
308 * the key on the wire is not the parameter's name and the lookup
309 * above can never find it. It also accumulates into a hash rather
310 * than replacing a value, so it is settled here, before the
311 * ordinary store. Object-typed, so the is_array gate that guards
312 * every other style does not apply. */
313 588 ▶ if (!pp) {
Branch: 1 branch
BranchTrueFalseTotal
if (!pp) { 21 567 588
314 21 STRLEN dkl; const char *dkp = SvPV_const(k, dkl);
315 14 ▶ const char *br = (dkl > 2 && dkp[dkl - 1] == ']')
Branch: 1 branch
BranchTrueFalseTotal
const char *br = (dkl > 2 && dkp[dkl - 1] == ']') 12 2 14
316 35 ▶ ? (const char *)memchr(dkp, '[', dkl) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? (const char *)memchr(dkp, '[', dkl) : NULL; 14 7 21
317 21 int deep = 0;
318 21 ▶ if (br && br > dkp) {
Branch: 2 branches
BranchTrueFalseTotal
if (br && br > dkp) { 12 9 21
if (br && br > dkp) { 12 0 12
319 12 STRLEN bl = (STRLEN)(br - dkp); /* the name */
320 12 STRLEN sbl = dkl - bl - 2; /* inside [ ] */
321 13 ▶ for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) { 12 1 13
322 12 oa_param *c = &o->params[OA_IN_QUERY][i];
323 12 STRLEN cnl; const char *cnp = SvPV_const(c->name, cnl);
324 SV **cur;
325 HV *bag;
326 12 ▶ if (c->style != OA_ST_DEEP) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (c->style != OA_ST_DEEP) continue; 1 11 12
327 11 ▶ if (cnl != bl || memNE(cnp, dkp, bl)) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (cnl != bl || memNE(cnp, dkp, bl)) continue; 11 0 11
if (cnl != bl || memNE(cnp, dkp, bl)) continue; 0 11 11
328 11 cur = hv_fetch(out, cnp, (I32)cnl, 0);
329 11 ▶ if (cur && *cur && SvROK(*cur)
Branch: 3 branches
BranchTrueFalseTotal
if (cur && *cur && SvROK(*cur) 6 5 11
if (cur && *cur && SvROK(*cur) 6 0 6
if (cur && *cur && SvROK(*cur) 6 0 6
330 6 ▶ && SvTYPE(SvRV(*cur)) == SVt_PVHV) {
Branch: 1 branch
BranchTrueFalseTotal
&& SvTYPE(SvRV(*cur)) == SVt_PVHV) { 6 0 6
331 6 bag = (HV *)SvRV(*cur);
332 } else {
333 5 bag = newHV();
334 5 (void)hv_store(out, cnp, (I32)cnl,
335 newRV_noinc((SV *)bag), 0);
336 }
337 11 (void)hv_store(bag, br + 1, (I32)sbl,
338 oa_pct_decode(aTHX_ rawv, rawvl, 1), 0);
339 11 deep = 1;
340 11 break;
341 }
342 }
343 /* form + explode on an object spreads the MEMBERS as top-level
344 * keys: `R=100&G=200&B=150`. Nothing on the wire ties them to
345 * the parameter, so the declared property names are the only
346 * link - which is why they are compiled in. A key matching no
347 * declared property falls through and is stored as itself. */
348 21 ▶ if (!deep) {
Branch: 1 branch
BranchTrueFalseTotal
if (!deep) { 10 11 21
349 15 ▶ for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) { 12 3 15
350 12 oa_param *c = &o->params[OA_IN_QUERY][i];
351 AV *names;
352 SSize_t pi, pn;
353 STRLEN cnl; const char *cnp;
354 12 ▶ if (!c->is_object || c->is_array) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (!c->is_object || c->is_array) continue; 7 5 12
if (!c->is_object || c->is_array) continue; 0 7 7
355 7 ▶ if (c->style != OA_ST_FORM || !c->explode) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (c->style != OA_ST_FORM || !c->explode) continue; 7 0 7
if (c->style != OA_ST_FORM || !c->explode) continue; 0 7 7
356 7 ▶ if (!c->props) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!c->props) continue; 0 7 7
357 7 names = (AV *)SvRV(c->props);
358 7 pn = av_len(names) + 1;
359 13 ▶ for (pi = 0; pi < pn; pi++) {
Branch: 1 branch
BranchTrueFalseTotal
for (pi = 0; pi < pn; pi++) { 13 0 13
360 13 SV **nm = av_fetch(names, pi, 0);
361 13 ▶ if (nm && *nm && sv_eq(*nm, k)) break;
Branch: 3 branches
BranchTrueFalseTotal
if (nm && *nm && sv_eq(*nm, k)) break; 13 0 13
if (nm && *nm && sv_eq(*nm, k)) break; 13 0 13
if (nm && *nm && sv_eq(*nm, k)) break; 7 6 13
362 }
363 7 ▶ if (pi == pn) continue; /* not a member */
Branch: 1 branch
BranchTrueFalseTotal
if (pi == pn) continue; /* not a member */ 0 7 7
364 7 cnp = SvPV_const(c->name, cnl);
365 {
366 7 SV **cur = hv_fetch(out, cnp, (I32)cnl, 0);
367 HV *bag;
368 7 ▶ if (cur && *cur && SvROK(*cur)
Branch: 3 branches
BranchTrueFalseTotal
if (cur && *cur && SvROK(*cur) 4 3 7
if (cur && *cur && SvROK(*cur) 4 0 4
if (cur && *cur && SvROK(*cur) 4 0 4
369 4 ▶ && SvTYPE(SvRV(*cur)) == SVt_PVHV) {
Branch: 1 branch
BranchTrueFalseTotal
&& SvTYPE(SvRV(*cur)) == SVt_PVHV) { 4 0 4
370 4 bag = (HV *)SvRV(*cur);
371 } else {
372 3 bag = newHV();
373 3 (void)hv_store(out, cnp, (I32)cnl,
374 newRV_noinc((SV *)bag), 0);
375 }
376 {
377 7 STRLEN mkl; const char *mkp = SvPV_const(k, mkl);
378 7 (void)hv_store(bag, mkp, (I32)mkl,
379 oa_pct_decode(aTHX_ rawv, rawvl, 1), 0);
380 }
381 7 deep = 1;
382 }
383 7 break;
384 }
385 }
386 21 ▶ if (deep) { s = e + 1; continue; }
Branch: 1 branch
BranchTrueFalseTotal
if (deep) { s = e + 1; continue; } 18 3 21
387 }
388 {
389 570 STRLEN kl; const char *kp = SvPV_const(k, kl);
390 570 int delimited = 0;
391  
392 /* an OBJECT arriving in one value: the same split as the list
393 * form, read as key,value pairs rather than as elements */
394 570 ▶ if (pp && pp->is_object && !pp->is_array) {
Branch: 3 branches
BranchTrueFalseTotal
if (pp && pp->is_object && !pp->is_array) { 567 3 570
if (pp && pp->is_object && !pp->is_array) { 6 561 567
if (pp && pp->is_object && !pp->is_array) { 6 0 6
395 6 SV *pieces = NULL;
396 6 ▶ if (pp->style == OA_ST_SPACE)
Branch: 1 branch
BranchTrueFalseTotal
if (pp->style == OA_ST_SPACE) 2 4 6
397 2 pieces = oa_split_tokens(aTHX_ rawv, rawvl, tok_space, 1);
398 4 ▶ else if (pp->style == OA_ST_PIPE)
Branch: 1 branch
BranchTrueFalseTotal
else if (pp->style == OA_ST_PIPE) 2 2 4
399 2 pieces = oa_split_tokens(aTHX_ rawv, rawvl, tok_pipe, 1);
400 2 ▶ else if (pp->style == OA_ST_FORM && !pp->explode)
Branch: 2 branches
BranchTrueFalseTotal
else if (pp->style == OA_ST_FORM && !pp->explode) 2 0 2
else if (pp->style == OA_ST_FORM && !pp->explode) 2 0 2
401 2 pieces = oa_split(aTHX_ rawv, rawvl, ',', 1, 1);
402 6 ▶ if (pieces) {
Branch: 1 branch
BranchTrueFalseTotal
if (pieces) { 6 0 6
403 6 SV *obj = oa_obj_from_pairs(aTHX_ sv_2mortal(pieces));
404 6 (void)hv_store(out, kp, (I32)kl, SvREFCNT_inc(obj), 0);
405 6 s = e + 1;
406 22 continue;
407 }
408 }
409  
410 /* a style whose list arrives in ONE value */
411 564 ▶ if (pp && pp->is_array) {
Branch: 2 branches
BranchTrueFalseTotal
if (pp && pp->is_array) { 561 3 564
if (pp && pp->is_array) { 30 531 561
412 30 ▶ if (pp->style == OA_ST_SPACE) {
Branch: 1 branch
BranchTrueFalseTotal
if (pp->style == OA_ST_SPACE) { 5 25 30
413 5 v = oa_split_tokens(aTHX_ rawv, rawvl, tok_space, 1);
414 5 delimited = 1;
415 }
416 25 ▶ else if (pp->style == OA_ST_PIPE) {
Branch: 1 branch
BranchTrueFalseTotal
else if (pp->style == OA_ST_PIPE) { 5 20 25
417 5 v = oa_split_tokens(aTHX_ rawv, rawvl, tok_pipe, 1);
418 5 delimited = 1;
419 }
420 20 ▶ else if (pp->style == OA_ST_FORM && !pp->explode) {
Branch: 2 branches
BranchTrueFalseTotal
else if (pp->style == OA_ST_FORM && !pp->explode) { 20 0 20
else if (pp->style == OA_ST_FORM && !pp->explode) { 6 14 20
421 6 v = oa_split(aTHX_ rawv, rawvl, ',', 1, 1);
422 6 delimited = 1;
423 }
424 }
425 564 ▶ if (delimited) {
Branch: 1 branch
BranchTrueFalseTotal
if (delimited) { 16 548 564
426 16 (void)hv_store(out, kp, (I32)kl, v, 0);
427 16 s = e + 1;
428 16 continue;
429 }
430  
431 548 v = oa_pct_decode(aTHX_ rawv, rawvl, 1);
432  
433 /* form + explode (the default): repeat keys accumulate.
434 * Unchanged, and it is what every document that declares no
435 * style at all goes through. */
436 562 ▶ if (pp && pp->is_array) {
Branch: 2 branches
BranchTrueFalseTotal
if (pp && pp->is_array) { 545 3 548
if (pp && pp->is_array) { 14 531 545
437 14 SV **cur = hv_fetch(out, kp, (I32)kl, 0);
438 AV *av;
439 14 ▶ if (cur && *cur && SvROK(*cur)
Branch: 3 branches
BranchTrueFalseTotal
if (cur && *cur && SvROK(*cur) 8 6 14
if (cur && *cur && SvROK(*cur) 8 0 8
if (cur && *cur && SvROK(*cur) 8 0 8
440 8 ▶ && SvTYPE(SvRV(*cur)) == SVt_PVAV) {
Branch: 1 branch
BranchTrueFalseTotal
&& SvTYPE(SvRV(*cur)) == SVt_PVAV) { 8 0 8
441 8 av = (AV *)SvRV(*cur);
442 } else {
443 6 av = newAV();
444 6 (void)hv_store(out, kp, (I32)kl,
445 newRV_noinc((SV *)av), 0);
446 }
447 14 av_push(av, v);
448 } else {
449 534 (void)hv_store(out, kp, (I32)kl, v, 0);
450 }
451 }
452 }
453 548 s = e + 1;
454 }
455 1166 return out;
456 }
457  
458 /* Parse a Cookie header ("a=b; c=d") into a fresh HV (raw values). */
459 16 static HV *oa_parse_cookies(pTHX_ const char *p, STRLEN l) {
460 16 HV *out = newHV();
461 16 STRLEN s = 0;
462 34 ▶ while (s < l) {
Branch: 1 branch
BranchTrueFalseTotal
while (s < l) { 18 16 34
463 18 STRLEN e = s, eq;
464 175 ▶ while (e < l && p[e] != ';') e++;
Branch: 2 branches
BranchTrueFalseTotal
while (e < l && p[e] != ';') e++; 159 16 175
while (e < l && p[e] != ';') e++; 157 2 159
465 20 ▶ while (s < e && isSPACE((U8)p[s])) s++;
Branch: 2 branches
BranchTrueFalseTotal
while (s < e && isSPACE((U8)p[s])) s++; 20 0 20
while (s < e && isSPACE((U8)p[s])) s++; 2 18 20
466 18 eq = s;
467 114 ▶ while (eq < e && p[eq] != '=') eq++;
Branch: 2 branches
BranchTrueFalseTotal
while (eq < e && p[eq] != '=') eq++; 114 0 114
while (eq < e && p[eq] != '=') eq++; 96 18 114
468 18 ▶ if (eq > s && eq < e) {
Branch: 2 branches
BranchTrueFalseTotal
if (eq > s && eq < e) { 18 0 18
if (eq > s && eq < e) { 18 0 18
469 18 STRLEN ve = e;
470 18 ▶ while (ve > eq + 1 && isSPACE((U8)p[ve - 1])) ve--;
Branch: 2 branches
BranchTrueFalseTotal
while (ve > eq + 1 && isSPACE((U8)p[ve - 1])) ve--; 18 0 18
while (ve > eq + 1 && isSPACE((U8)p[ve - 1])) ve--; 0 18 18
471 18 (void)hv_store(out, p + s, (I32)(eq - s),
472 newSVpvn(p + eq + 1, ve - eq - 1), 0);
473 }
474 18 s = e + 1;
475 }
476 16 return out;
477 }
478  
479 /* ---- body ------------------------------------------------------------------- */
480  
481 /* The declared entry covering this Content-Type, most specific first: an
482 * exact type beats a type-level range, which beats the catch-all range.
483 * Matching is case-insensitive per RFC 7231 and ignores parameters; NULL when
484 * nothing declared covers the type. */
485 1954 static oa_body *oa_body_for(pTHX_ oa_op *o, SV *ctype_hdr) {
486 STRLEN l;
487 const char *p;
488 int i;
489 1954 oa_body *star = NULL, *type_star = NULL;
490 1954 ▶ if (!o->nbodies) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!o->nbodies) return NULL; 0 1954 1954
491 1954 ▶ if (!ctype_hdr || !SvOK(ctype_hdr)) return NULL;
Branch: 2 branches
BranchTrueFalseTotal
if (!ctype_hdr || !SvOK(ctype_hdr)) return NULL; 1953 1 1954
if (!ctype_hdr || !SvOK(ctype_hdr)) return NULL; 0 1953 1953
492 1953 p = SvPV_const(ctype_hdr, l);
493 1968 ▶ for (i = 0; i < o->nbodies; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nbodies; i++) { 1963 5 1968
494 1963 STRLEN cl; const char *cp = SvPV_const(o->bodies[i].ctype, cl);
495 STRLEN cb, ce;
496 1963 oa_ctype_span(cp, cl, &cb, &ce);
497 1963 ▶ if (ce - cb == 3 && memEQ(cp + cb, "*/*", 3)) {
Branch: 2 branches
BranchTrueFalseTotal
if (ce - cb == 3 && memEQ(cp + cb, "*/*", 3)) { 3 1960 1963
if (ce - cb == 3 && memEQ(cp + cb, "*/*", 3)) { 3 0 3
498 3 ▶ if (!star) star = &o->bodies[i];
Branch: 1 branch
BranchTrueFalseTotal
if (!star) star = &o->bodies[i]; 3 0 3
499 3 continue;
500 }
501 1960 ▶ if ((ce - cb) > 2 && cp[ce - 1] == '*' && cp[ce - 2] == '/') {
Branch: 3 branches
BranchTrueFalseTotal
if ((ce - cb) > 2 && cp[ce - 1] == '*' && cp[ce - 2] == '/') { 1960 0 1960
if ((ce - cb) > 2 && cp[ce - 1] == '*' && cp[ce - 2] == '/') { 0 1960 1960
if ((ce - cb) > 2 && cp[ce - 1] == '*' && cp[ce - 2] == '/') { 0 0 0
502 0 ▶ if (!type_star && oa_ctype_matches(cp, cl, p, l))
Branch: 2 branches
BranchTrueFalseTotal
if (!type_star && oa_ctype_matches(cp, cl, p, l)) 0 0 0
if (!type_star && oa_ctype_matches(cp, cl, p, l)) 0 0 0
503 0 type_star = &o->bodies[i];
504 0 continue;
505 }
506 1960 ▶ if (oa_ctype_matches(cp, cl, p, l)) return &o->bodies[i];
Branch: 1 branch
BranchTrueFalseTotal
if (oa_ctype_matches(cp, cl, p, l)) return &o->bodies[i]; 1948 12 1960
507 }
508 5 ▶ return type_star ? type_star : star;
Branch: 1 branch
BranchTrueFalseTotal
return type_star ? type_star : star; 0 5 5
509 }
510  
511 /* ---- form bodies ------------------------------------------------------------
512 *
513 * Neither of these goes through the frj ABI: a form body is not JSON. They
514 * build the same shape a decoded JSON object would have, so one schema
515 * validates either spelling.
516 *
517 * A repeat key becomes an arrayref, because a form carries repeats naturally
518 * (checkboxes, multi-selects) and a schema saying `type: array` must see one. */
519 31 static void oa_form_add(pTHX_ HV *out, SV *key, SV *val) {
520 31 STRLEN kl; const char *kp = SvPV_const(key, kl);
521 31 SV **cur = hv_fetch(out, kp, (I32)kl, 0);
522 31 ▶ if (cur && *cur) {
Branch: 2 branches
BranchTrueFalseTotal
if (cur && *cur) { 2 29 31
if (cur && *cur) { 2 0 2
523 AV *list;
524 2 ▶ if (SvROK(*cur) && SvTYPE(SvRV(*cur)) == SVt_PVAV) list = (AV *)SvRV(*cur);
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(*cur) && SvTYPE(SvRV(*cur)) == SVt_PVAV) list = (AV *)SvRV(*cur); 0 2 2
if (SvROK(*cur) && SvTYPE(SvRV(*cur)) == SVt_PVAV) list = (AV *)SvRV(*cur); 0 0 0
525 else {
526 2 list = newAV();
527 2 av_push(list, newSVsv(*cur));
528 2 (void)hv_store(out, kp, (I32)kl, newRV_noinc((SV *)list), 0);
529 }
530 2 av_push(list, val);
531 2 return;
532 }
533 29 (void)hv_store(out, kp, (I32)kl, val, 0);
534 }
535  
536 /* application/x-www-form-urlencoded. Mortal hashref; never NULL - an empty
537 * body is an empty object, which a schema is entitled to reject. */
538 17 static SV *oa_form_decode(pTHX_ SV *text, SV *encoding) {
539 17 STRLEN l; const char *p = SvPV_const(text, l);
540 17 HV *out = newHV();
541 9 ▶ HV *enc = (encoding && SvROK(encoding)
Branch: 1 branch
BranchTrueFalseTotal
HV *enc = (encoding && SvROK(encoding) 9 0 9
542 9 ▶ && SvTYPE(SvRV(encoding)) == SVt_PVHV)
Branch: 1 branch
BranchTrueFalseTotal
&& SvTYPE(SvRV(encoding)) == SVt_PVHV) 9 0 9
543 26 ▶ ? (HV *)SvRV(encoding) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? (HV *)SvRV(encoding) : NULL; 9 8 17
544 17 STRLEN s = 0;
545 37 ▶ while (s < l) {
Branch: 1 branch
BranchTrueFalseTotal
while (s < l) { 20 17 37
546 20 STRLEN e = s, eq;
547 158 ▶ while (e < l && p[e] != '&') e++;
Branch: 2 branches
BranchTrueFalseTotal
while (e < l && p[e] != '&') e++; 141 17 158
while (e < l && p[e] != '&') e++; 138 3 141
548 20 eq = s;
549 49 ▶ while (eq < e && p[eq] != '=') eq++;
Branch: 2 branches
BranchTrueFalseTotal
while (eq < e && p[eq] != '=') eq++; 49 0 49
while (eq < e && p[eq] != '=') eq++; 29 20 49
550 20 ▶ if (eq > s) {
Branch: 1 branch
BranchTrueFalseTotal
if (eq > s) { 20 0 20
551 20 SV *k = sv_2mortal(oa_pct_decode(aTHX_ p + s, eq - s, 1));
552 20 ▶ const char *rawv = p + (eq < e ? eq + 1 : e);
Branch: 1 branch
BranchTrueFalseTotal
const char *rawv = p + (eq < e ? eq + 1 : e); 20 0 20
553 20 ▶ STRLEN rawvl = eq < e ? e - eq - 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
STRLEN rawvl = eq < e ? e - eq - 1 : 0; 20 0 20
554 20 SV *v = NULL;
555 /* An Encoding Object may say this property is a delimited list.
556 * The split is on the RAW span, BEFORE decoding, so an escaped
557 * delimiter stays inside its element - `a=x%2Cy` is one value
558 * containing a comma, not two values. Same asymmetry the query
559 * styles turn on, and the reason the encoding has to reach the
560 * decoder rather than being applied to its output. */
561 20 ▶ if (enc) {
Branch: 1 branch
BranchTrueFalseTotal
if (enc) { 9 11 20
562 9 STRLEN kl2; const char *kp2 = SvPV_const(k, kl2);
563 9 SV **es = hv_fetch(enc, kp2, (I32)kl2, 0);
564 9 ▶ HV *eh = (es && *es) ? oa_hv_of(*es) : NULL;
Branch: 2 branches
BranchTrueFalseTotal
HV *eh = (es && *es) ? oa_hv_of(*es) : NULL; 9 0 9
HV *eh = (es && *es) ? oa_hv_of(*es) : NULL; 9 0 9
565 9 ▶ if (eh) {
Branch: 1 branch
BranchTrueFalseTotal
if (eh) { 9 0 9
566 9 SV *st = oa_get(aTHX_ eh, "style");
567 9 SV *ex = oa_get(aTHX_ eh, "explode");
568 9 STRLEN sl2 = 0;
569 14 ▶ const char *sp2 = st ? SvPV_const(st, sl2) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
const char *sp2 = st ? SvPV_const(st, sl2) : NULL; 5 4 9
570 /* `form` is the default style here, and it explodes by
571 * default - so only an explicit explode:false makes a
572 * form property a delimited list */
573 9 ▶ int exploded = ex ? (oa_sv_truthy(aTHX_ ex) ? 1 : 0) : 1;
Branch: 2 branches
BranchTrueFalseTotal
int exploded = ex ? (oa_sv_truthy(aTHX_ ex) ? 1 : 0) : 1; 5 4 9
int exploded = ex ? (oa_sv_truthy(aTHX_ ex) ? 1 : 0) : 1; 0 5 5
574 9 ▶ int isform = !sp2 || (sl2 == 4 && memEQ(sp2, "form", 4));
Branch: 3 branches
BranchTrueFalseTotal
int isform = !sp2 || (sl2 == 4 && memEQ(sp2, "form", 4)); 5 4 9
int isform = !sp2 || (sl2 == 4 && memEQ(sp2, "form", 4)); 5 0 5
int isform = !sp2 || (sl2 == 4 && memEQ(sp2, "form", 4)); 5 0 5
575 9 ▶ int isspace = sp2 && sl2 == 14 && memEQ(sp2, "spaceDelimited", 14);
Branch: 3 branches
BranchTrueFalseTotal
int isspace = sp2 && sl2 == 14 && memEQ(sp2, "spaceDelimited", 14); 5 4 9
int isspace = sp2 && sl2 == 14 && memEQ(sp2, "spaceDelimited", 14); 0 5 5
int isspace = sp2 && sl2 == 14 && memEQ(sp2, "spaceDelimited", 14); 0 0 0
576 9 ▶ int ispipe = sp2 && sl2 == 13 && memEQ(sp2, "pipeDelimited", 13);
Branch: 3 branches
BranchTrueFalseTotal
int ispipe = sp2 && sl2 == 13 && memEQ(sp2, "pipeDelimited", 13); 5 4 9
int ispipe = sp2 && sl2 == 13 && memEQ(sp2, "pipeDelimited", 13); 0 5 5
int ispipe = sp2 && sl2 == 13 && memEQ(sp2, "pipeDelimited", 13); 0 0 0
577 9 ▶ if (isform && !exploded)
Branch: 2 branches
BranchTrueFalseTotal
if (isform && !exploded) 9 0 9
if (isform && !exploded) 5 4 9
578 5 v = oa_split(aTHX_ rawv, rawvl, ',', 1, 1);
579 4 ▶ else if (isspace) {
Branch: 1 branch
BranchTrueFalseTotal
else if (isspace) { 0 4 4
580 static const char *const tok_sp[] = { "%20", "+", " ", NULL };
581 0 v = oa_split_tokens(aTHX_ rawv, rawvl, tok_sp, 1);
582 }
583 4 ▶ else if (ispipe) {
Branch: 1 branch
BranchTrueFalseTotal
else if (ispipe) { 0 4 4
584 static const char *const tok_pp[] = { "%7C", "%7c", "|", NULL };
585 0 v = oa_split_tokens(aTHX_ rawv, rawvl, tok_pp, 1);
586 }
587 }
588 }
589 20 ▶ if (!v) v = oa_pct_decode(aTHX_ rawv, rawvl, 1);
Branch: 1 branch
BranchTrueFalseTotal
if (!v) v = oa_pct_decode(aTHX_ rawv, rawvl, 1); 15 5 20
590 20 oa_form_add(aTHX_ out, k, v);
591 }
592 20 s = e + 1;
593 }
594 17 return sv_2mortal(newRV_noinc((SV *)out));
595 }
596  
597 /* Apply an Encoding Object to a decoded form body. A property whose encoding
598 * names a JSON media type carries a whole document in one field - the
599 * `a={"n":"x"}` idiom - so it is decoded before the schema sees it, exactly
600 * as a parameter declared with `content` is. A field that is already a
601 * reference (a repeat promoted to an arrayref) is left alone, and a value
602 * that will not decode is left as text for the schema to refuse. */
603 13 static void oa_apply_encoding(pTHX_ SV *data, SV *encoding) {
604 HV *d, *e;
605 HE *he;
606 13 ▶ if (!data || !SvROK(data) || SvTYPE(SvRV(data)) != SVt_PVHV) return;
Branch: 3 branches
BranchTrueFalseTotal
if (!data || !SvROK(data) || SvTYPE(SvRV(data)) != SVt_PVHV) return; 13 0 13
if (!data || !SvROK(data) || SvTYPE(SvRV(data)) != SVt_PVHV) return; 13 0 13
if (!data || !SvROK(data) || SvTYPE(SvRV(data)) != SVt_PVHV) return; 0 13 13
607 13 ▶ if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) return;
Branch: 3 branches
BranchTrueFalseTotal
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) return; 13 0 13
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) return; 13 0 13
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) return; 0 13 13
608 13 d = (HV *)SvRV(data);
609 13 e = (HV *)SvRV(encoding);
610 13 hv_iterinit(e);
611 26 ▶ while ((he = hv_iternext(e))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(e))) { 13 13 26
612 13 I32 kl; const char *k = hv_iterkey(he, &kl);
613 13 HV *spec = oa_hv_of(hv_iterval(e, he));
614 13 ▶ SV *ct = spec ? oa_get(aTHX_ spec, "contentType") : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV *ct = spec ? oa_get(aTHX_ spec, "contentType") : NULL; 13 0 13
615 SV **slot;
616 STRLEN cl; const char *cp;
617 13 ▶ if (!ct) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!ct) continue; 10 3 13
618 3 cp = SvPV_const(ct, cl);
619 3 ▶ if (!oa_ctype_is_json(cp, cl)) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_ctype_is_json(cp, cl)) continue; 0 3 3
620 3 slot = hv_fetch(d, k, kl, 0);
621 3 ▶ if (slot && *slot && SvOK(*slot) && !SvROK(*slot)) {
Branch: 4 branches
BranchTrueFalseTotal
if (slot && *slot && SvOK(*slot) && !SvROK(*slot)) { 3 0 3
if (slot && *slot && SvOK(*slot) && !SvROK(*slot)) { 3 0 3
if (slot && *slot && SvOK(*slot) && !SvROK(*slot)) { 3 0 3
if (slot && *slot && SvOK(*slot) && !SvROK(*slot)) { 3 0 3
622 3 SV *dec = oa_body_decode(aTHX_ *slot);
623 3 ▶ if (dec) (void)hv_store(d, k, kl, newSVsv(dec), 0);
Branch: 1 branch
BranchTrueFalseTotal
if (dec) (void)hv_store(d, k, kl, newSVsv(dec), 0); 3 0 3
624 }
625 }
626 }
627  
628 /* An Encoding Object may declare `headers` for a multipart part - a map of
629 * Header Objects, exactly as a response declares them. A declared `required`
630 * header that the part does not carry is a bad request, and nothing else
631 * would report it: the part's headers are not part of the value the schema
632 * sees. Header names are compared case-insensitively, per RFC 7231. */
633 13 static int oa_check_encoding_headers(pTHX_ SV *encoding, HV *part_hdrs,
634 AV *errs) {
635 HV *e;
636 HE *he;
637 13 int ok = 1;
638 13 ▶ if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV)
Branch: 3 branches
BranchTrueFalseTotal
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) 13 0 13
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) 13 0 13
if (!encoding || !SvROK(encoding) || SvTYPE(SvRV(encoding)) != SVt_PVHV) 0 13 13
639 0 return 1;
640 13 ▶ if (!part_hdrs) return 1;
Branch: 1 branch
BranchTrueFalseTotal
if (!part_hdrs) return 1; 9 4 13
641 4 e = (HV *)SvRV(encoding);
642 4 hv_iterinit(e);
643 8 ▶ while ((he = hv_iternext(e))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(e))) { 4 4 8
644 4 I32 pkl; const char *pk = hv_iterkey(he, &pkl);
645 4 HV *spec = oa_hv_of(hv_iterval(e, he));
646 4 ▶ HV *want = spec ? oa_hv_of(oa_get(aTHX_ spec, "headers")) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
HV *want = spec ? oa_hv_of(oa_get(aTHX_ spec, "headers")) : NULL; 4 0 4
647 4 SV **got = hv_fetch(part_hdrs, pk, pkl, 0);
648 4 ▶ HV *have = (got && *got) ? oa_hv_of(*got) : NULL;
Branch: 2 branches
BranchTrueFalseTotal
HV *have = (got && *got) ? oa_hv_of(*got) : NULL; 4 0 4
HV *have = (got && *got) ? oa_hv_of(*got) : NULL; 4 0 4
649 HE *whe;
650 4 ▶ if (!want) continue;
Branch: 1 branch
BranchTrueFalseTotal
if (!want) continue; 0 4 4
651 4 hv_iterinit(want);
652 8 ▶ while ((whe = hv_iternext(want))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((whe = hv_iternext(want))) { 4 4 8
653 4 I32 hkl; const char *hk = hv_iterkey(whe, &hkl);
654 4 HV *hspec = oa_hv_of(hv_iterval(want, whe));
655 4 ▶ SV *req = hspec ? oa_get(aTHX_ hspec, "required") : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV *req = hspec ? oa_get(aTHX_ hspec, "required") : NULL; 4 0 4
656 4 int found = 0;
657 4 ▶ if (!req || !oa_sv_truthy(aTHX_ req)) continue;
Branch: 2 branches
BranchTrueFalseTotal
if (!req || !oa_sv_truthy(aTHX_ req)) continue; 4 0 4
if (!req || !oa_sv_truthy(aTHX_ req)) continue; 0 4 4
658 4 ▶ if (have) {
Branch: 1 branch
BranchTrueFalseTotal
if (have) { 4 0 4
659 HE *ghe;
660 4 hv_iterinit(have);
661 7 ▶ while ((ghe = hv_iternext(have))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((ghe = hv_iternext(have))) { 5 2 7
662 5 I32 gkl; const char *gk = hv_iterkey(ghe, &gkl);
663 5 ▶ if (oa_ci_eq(gk, (STRLEN)gkl, hk, (STRLEN)hkl))
Branch: 1 branch
BranchTrueFalseTotal
if (oa_ci_eq(gk, (STRLEN)gkl, hk, (STRLEN)hkl)) 2 3 5
664 2 { found = 1; break; }
665 }
666 }
667 4 ▶ if (!found) {
Branch: 1 branch
BranchTrueFalseTotal
if (!found) { 2 2 4
668 2 ok = 0;
669 2 ▶ if (errs) {
Branch: 1 branch
BranchTrueFalseTotal
if (errs) { 2 0 2
670 2 SV *nm = sv_2mortal(newSVpvn(hk, (STRLEN)hkl));
671 2 oa_err_push(aTHX_ errs, "body", nm, "required",
672 "multipart part is missing a required "
673 "encoding header");
674 }
675 }
676 }
677 }
678 4 return ok;
679 }
680  
681 /* the value of a header parameter: name=value or name="value" */
682 19 static const char *oa_hdr_param(const char *s, STRLEN sl, const char *name,
683 STRLEN *vl) {
684 19 STRLEN nl = strlen(name), i;
685 539 ▶ for (i = 0; i + nl + 1 <= sl; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i + nl + 1 <= sl; i++) { 539 0 539
686 539 ▶ if ((i == 0 || s[i-1] == ' ' || s[i-1] == ';' || s[i-1] == '\t')
Branch: 4 branches
BranchTrueFalseTotal
if ((i == 0 || s[i-1] == ' ' || s[i-1] == ';' || s[i-1] == '\t') 520 19 539
if ((i == 0 || s[i-1] == ' ' || s[i-1] == ';' || s[i-1] == '\t') 490 30 520
if ((i == 0 || s[i-1] == ' ' || s[i-1] == ';' || s[i-1] == '\t') 471 19 490
if ((i == 0 || s[i-1] == ' ' || s[i-1] == ';' || s[i-1] == '\t') 0 471 471
687 68 ▶ && oa_ci_eq(s + i, nl, name, nl) && s[i + nl] == '=') {
Branch: 2 branches
BranchTrueFalseTotal
&& oa_ci_eq(s + i, nl, name, nl) && s[i + nl] == '=') { 19 49 68
&& oa_ci_eq(s + i, nl, name, nl) && s[i + nl] == '=') { 19 0 19
688 19 const char *v = s + i + nl + 1;
689 const char *e;
690 19 ▶ if (v < s + sl && *v == '"') { v++; e = v;
Branch: 2 branches
BranchTrueFalseTotal
if (v < s + sl && *v == '"') { v++; e = v; 19 0 19
if (v < s + sl && *v == '"') { v++; e = v; 11 8 19
691 25 ▶ while (e < s + sl && *e != '"') e++; }
Branch: 2 branches
BranchTrueFalseTotal
while (e < s + sl && *e != '"') e++; } 25 0 25
while (e < s + sl && *e != '"') e++; } 14 11 25
692 44 ▶ else { e = v; while (e < s + sl && *e != ';') e++; }
Branch: 2 branches
BranchTrueFalseTotal
else { e = v; while (e < s + sl && *e != ';') e++; } 36 8 44
else { e = v; while (e < s + sl && *e != ';') e++; } 36 0 36
693 19 *vl = (STRLEN)(e - v);
694 19 return v;
695 }
696 }
697 0 return NULL;
698 }
699  
700 /* multipart/form-data. The boundary lives in the Content-Type's parameters,
701 * which is why the FULL header is needed here and not the trimmed type.
702 * Field parts become values; a part with a filename keeps its content, since
703 * a schema can only speak about what is in the body. NULL when there is no
704 * boundary to walk - that is a malformed request, not an empty one. */
705 /* `part_hdrs`, when given, is filled with part name => { header => value }.
706 * The decoded body itself stays a plain name => value map, because that is
707 * what the schema validates - an Encoding Object's declared headers are a
708 * separate question, asked separately. Pass NULL to not collect them. */
709 8 static SV *oa_multipart_decode(pTHX_ SV *text, const char *ct, STRLEN ctl,
710 HV *part_hdrs) {
711 8 STRLEN bl = 0, l;
712 8 const char *bp = oa_hdr_param(ct, ctl, "boundary", &bl);
713 const char *body, *end, *p;
714 SV *dash;
715 HV *out;
716 8 ▶ if (!bp || !bl) return NULL;
Branch: 2 branches
BranchTrueFalseTotal
if (!bp || !bl) return NULL; 8 0 8
if (!bp || !bl) return NULL; 0 8 8
717 8 body = SvPV_const(text, l);
718 8 end = body + l;
719 8 dash = sv_2mortal(newSVpvs("--"));
720 8 sv_catpvn(dash, bp, bl);
721 {
722 8 char *dp = SvPVX(dash);
723 8 STRLEN dl = SvCUR(dash);
724 8 p = ninstr((char *)body, (char *)end, dp, dp + dl);
725 8 ▶ if (!p) return NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (!p) return NULL; 0 8 8
726 8 out = newHV();
727 8 p += dl;
728 19 ▶ while (p < end) {
Branch: 1 branch
BranchTrueFalseTotal
while (p < end) { 19 0 19
729 const char *hend, *nd, *content, *hp;
730 19 STRLEN nlen = 0;
731 19 const char *nm = NULL;
732 HV *hdrs_here;
733 19 ▶ if (p + 2 <= end && p[0] == '-' && p[1] == '-') break; /* closing */
Branch: 3 branches
BranchTrueFalseTotal
if (p + 2 <= end && p[0] == '-' && p[1] == '-') break; /* closing */ 19 0 19
if (p + 2 <= end && p[0] == '-' && p[1] == '-') break; /* closing */ 8 11 19
if (p + 2 <= end && p[0] == '-' && p[1] == '-') break; /* closing */ 8 0 8
734 33 ▶ while (p < end && (*p == '\r' || *p == '\n')) p++;
Branch: 3 branches
BranchTrueFalseTotal
while (p < end && (*p == '\r' || *p == '\n')) p++; 33 0 33
while (p < end && (*p == '\r' || *p == '\n')) p++; 11 22 33
while (p < end && (*p == '\r' || *p == '\n')) p++; 11 11 22
735 { /* both ends of the needle must come from ONE object: two
736 * spellings of the same literal are two objects, so `lit + n`
737 * would point past a different array than `lit` */
738 11 const char *crlf2 = "\r\n\r\n";
739 11 hend = ninstr((char *)p, (char *)end,
740 (char *)crlf2, (char *)crlf2 + 4);
741 }
742 11 ▶ if (!hend) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!hend) break; 0 11 11
743 11 ▶ hdrs_here = part_hdrs ? (HV *)sv_2mortal((SV *)newHV()) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
hdrs_here = part_hdrs ? (HV *)sv_2mortal((SV *)newHV()) : NULL; 4 7 11
744 13 ▶ for (hp = p; hp < hend; ) {
Branch: 1 branch
BranchTrueFalseTotal
for (hp = p; hp < hend; ) { 13 0 13
745 13 const char *crlf = "\r\n";
746 13 const char *le = ninstr((char *)hp, (char *)hend,
747 (char *)crlf, (char *)crlf + 2);
748 13 ▶ STRLEN ll = (STRLEN)((le ? le : hend) - hp);
Branch: 1 branch
BranchTrueFalseTotal
STRLEN ll = (STRLEN)((le ? le : hend) - hp); 2 11 13
749 13 ▶ if (ll >= 20 && oa_ci_eq(hp, 20, "Content-Disposition:", 20))
Branch: 2 branches
BranchTrueFalseTotal
if (ll >= 20 && oa_ci_eq(hp, 20, "Content-Disposition:", 20)) 11 2 13
if (ll >= 20 && oa_ci_eq(hp, 20, "Content-Disposition:", 20)) 11 0 11
750 11 nm = oa_hdr_param(hp, ll, "name", &nlen);
751 /* every header line, kept for the encoding check. The name is
752 * everything before the colon; the value is what follows,
753 * with leading space trimmed. */
754 13 ▶ if (hdrs_here) {
Branch: 1 branch
BranchTrueFalseTotal
if (hdrs_here) { 6 7 13
755 6 STRLEN c = 0;
756 88 ▶ while (c < ll && hp[c] != ':') c++;
Branch: 2 branches
BranchTrueFalseTotal
while (c < ll && hp[c] != ':') c++; 88 0 88
while (c < ll && hp[c] != ':') c++; 82 6 88
757 6 ▶ if (c > 0 && c < ll) {
Branch: 2 branches
BranchTrueFalseTotal
if (c > 0 && c < ll) { 6 0 6
if (c > 0 && c < ll) { 6 0 6
758 6 STRLEN vs = c + 1;
759 12 ▶ while (vs < ll && (hp[vs] == ' ' || hp[vs] == '\t')) vs++;
Branch: 3 branches
BranchTrueFalseTotal
while (vs < ll && (hp[vs] == ' ' || hp[vs] == '\t')) vs++; 12 0 12
while (vs < ll && (hp[vs] == ' ' || hp[vs] == '\t')) vs++; 6 6 12
while (vs < ll && (hp[vs] == ' ' || hp[vs] == '\t')) vs++; 0 6 6
760 6 (void)hv_store(hdrs_here, hp, (I32)c,
761 newSVpvn(hp + vs, ll - vs), 0);
762 }
763 }
764 13 ▶ if (!le) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!le) break; 11 2 13
765 2 hp = le + 2;
766 }
767 11 content = hend + 4;
768 11 nd = ninstr((char *)content, (char *)end, dp, dp + dl);
769 11 ▶ if (!nd) break;
Branch: 1 branch
BranchTrueFalseTotal
if (!nd) break; 0 11 11
770 11 ▶ if (nm) {
Branch: 1 branch
BranchTrueFalseTotal
if (nm) { 11 0 11
771 11 STRLEN clen = (STRLEN)(nd - content);
772 22 ▶ while (clen >= 2 && content[clen-1] == '\n' && content[clen-2] == '\r')
Branch: 3 branches
BranchTrueFalseTotal
while (clen >= 2 && content[clen-1] == '\n' && content[clen-2] == '\r') 16 6 22
while (clen >= 2 && content[clen-1] == '\n' && content[clen-2] == '\r') 11 5 16
while (clen >= 2 && content[clen-1] == '\n' && content[clen-2] == '\r') 11 0 11
773 11 clen -= 2; /* the CRLF before --bound */
774 11 oa_form_add(aTHX_ out, sv_2mortal(newSVpvn(nm, nlen)),
775 newSVpvn(content, clen));
776 11 ▶ if (part_hdrs && hdrs_here)
Branch: 2 branches
BranchTrueFalseTotal
if (part_hdrs && hdrs_here) 4 7 11
if (part_hdrs && hdrs_here) 4 0 4
777 4 (void)hv_store(part_hdrs, nm, (I32)nlen,
778 newRV_inc((SV *)hdrs_here), 0);
779 }
780 11 p = nd + dl;
781 }
782 }
783 8 return sv_2mortal(newRV_noinc((SV *)out));
784 }
785  
786 /* Decode JSON text through the frj ABI. The ABI croaks on malformed input,
787 * so the decode runs inside the private _frj_decode trampoline (a direct ABI
788 * call), invoked here on its cached CV with G_EVAL - a bad request body
789 * becomes a 400, never an escaped die. Mortal SV on success, NULL on parse
790 * failure. OA_DEC_CV is resolved in BOOT (API.xs). */
791 static SV *OA_DEC_CV = NULL;
792 static SV *OA_ENC_CV = NULL;
793  
794 /* `*ok` separates the two things a NULL return used to mean: the text was not
795 * JSON at all, and the text was the JSON document `null`. They are not the
796 * same - `null` is a valid JSON text (RFC 8259) and `type: null` is a valid
797 * 3.1 schema, which is also what a 3.0 `nullable` converts INTO - and folding
798 * them together reported a conforming null body as malformed JSON.
799 *
800 * On success with a null document this returns NULL with *ok true, so a caller
801 * that does not care keeps its old behaviour exactly. */
802 3008 static SV *oa_body_decode_ok(pTHX_ SV *text, int *ok) {
803 3008 dSP; int count; SV *ret = NULL;
804 3008 *ok = 0;
805 3008 ▶ ENTER; SAVETMPS; PUSHMARK(SP);
Branch: 1 branch
BranchTrueFalseTotal
ENTER; SAVETMPS; PUSHMARK(SP); 0 3008 3008
806 3008 ▶ XPUSHs(text); PUTBACK;
Branch: 1 branch
BranchTrueFalseTotal
XPUSHs(text); PUTBACK; 0 3008 3008
807 3008 count = call_sv(OA_DEC_CV, G_SCALAR | G_EVAL);
808 3008 SPAGAIN;
809 6014 ▶ if (!SvTRUE(ERRSV) && count > 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (!SvTRUE(ERRSV) && count > 0) { 3008 0 3008
if (!SvTRUE(ERRSV) && count > 0) { 3006 2 3008
if (!SvTRUE(ERRSV) && count > 0) { 3006 0 3006
810 3006 SV *r = POPs;
811 3006 *ok = 1;
812 3006 ▶ if (SvOK(r)) ret = newSVsv(r);
Branch: 1 branch
BranchTrueFalseTotal
if (SvOK(r)) ret = newSVsv(r); 2938 68 3006
813 }
814 2 ▶ else if (count > 0) (void)POPs;
Branch: 1 branch
BranchTrueFalseTotal
else if (count > 0) (void)POPs; 2 0 2
815 3008 ▶ PUTBACK; FREETMPS; LEAVE;
Branch: 1 branch
BranchTrueFalseTotal
PUTBACK; FREETMPS; LEAVE; 3008 0 3008
816 3008 ▶ return ret ? sv_2mortal(ret) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
return ret ? sv_2mortal(ret) : NULL; 2938 70 3008
817 }
818  
819 1108 static SV *oa_body_decode(pTHX_ SV *text) {
820 int ok;
821 1108 return oa_body_decode_ok(aTHX_ text, &ok);
822 }
823  
824 /* ---- the validation pipeline ------------------------------------------------ */
825  
826 /* Validate a matched operation's inputs. All arguments may be NULL/absent
827 * except the op. Returns 1/0; params_out (if non-NULL) receives a fresh HV
828 * { path, query, header, cookie, body } on success. */
829 4306 static int oa_validate_op(pTHX_ oa_api *a, oa_op *o,
830 HV *rawpath, SV *query, HV *headers, SV *body_raw,
831 HV **params_out, AV *errs) {
832 4306 HV *out = newHV();
833 4306 HV *op_ = newHV(), *oq = NULL, *oh = newHV(), *oc = newHV();
834 4306 int ok = 1, i;
835 PERL_UNUSED_ARG(a);
836  
837 /* path captures: decode, validate, store */
838 6515 ▶ for (i = 0; i < o->nparams[OA_IN_PATH]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_PATH]; i++) { 2209 4306 6515
839 2209 oa_param *pp = &o->params[OA_IN_PATH][i];
840 2209 STRLEN nl; const char *np = SvPV_const(pp->name, nl);
841 2209 ▶ SV **raw = rawpath ? hv_fetch(rawpath, np, (I32)nl, 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV **raw = rawpath ? hv_fetch(rawpath, np, (I32)nl, 0) : NULL; 2208 1 2209
842 4417 ▶ if (raw && *raw && SvOK(*raw)) {
Branch: 3 branches
BranchTrueFalseTotal
if (raw && *raw && SvOK(*raw)) { 2208 1 2209
if (raw && *raw && SvOK(*raw)) { 2208 0 2208
if (raw && *raw && SvOK(*raw)) { 2208 0 2208
843 2208 STRLEN vl; const char *vp = SvPV_const(*raw, vl);
844 2208 SV *dec = oa_style_path(aTHX_ pp, vp, vl);
845 2208 ▶ if (!oa_check_param(aTHX_ pp, dec, errs, "path")) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check_param(aTHX_ pp, dec, errs, "path")) ok = 0; 508 1700 2208
846 1700 else (void)hv_store(op_, np, (I32)nl, SvREFCNT_inc(dec), 0);
847 } else {
848 1 ok = 0;
849 1 ▶ if (errs) oa_err_push(aTHX_ errs, "path", pp->name,
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "path", pp->name, 1 0 1
850 "required", "missing required path parameter");
851 }
852 2209 ▶ if (!ok && !errs) goto done;
Branch: 2 branches
BranchTrueFalseTotal
if (!ok && !errs) goto done; 509 1700 2209
if (!ok && !errs) goto done; 0 509 509
853 }
854  
855 /* query: string -> parse; hashref -> use as given */
856 4314 ▶ if (query && SvROK(query) && SvTYPE(SvRV(query)) == SVt_PVHV) {
Branch: 3 branches
BranchTrueFalseTotal
if (query && SvROK(query) && SvTYPE(SvRV(query)) == SVt_PVHV) { 1174 3132 4306
if (query && SvROK(query) && SvTYPE(SvRV(query)) == SVt_PVHV) { 8 1166 1174
if (query && SvROK(query) && SvTYPE(SvRV(query)) == SVt_PVHV) { 8 0 8
857 8 HV *src = (HV *)SvRV(query);
858 HE *he;
859 8 oq = newHV();
860 8 hv_iterinit(src);
861 15 ▶ while ((he = hv_iternext(src))) {
Branch: 1 branch
BranchTrueFalseTotal
while ((he = hv_iternext(src))) { 7 8 15
862 7 I32 kl; const char *k = hv_iterkey(he, &kl);
863 7 (void)hv_store(oq, k, kl, newSVsv(hv_iterval(src, he)), 0);
864 }
865 5464 ▶ } else if (query && SvOK(query)) {
Branch: 2 branches
BranchTrueFalseTotal
} else if (query && SvOK(query)) { 1166 3132 4298
} else if (query && SvOK(query)) { 1166 0 1166
866 1166 STRLEN ql; const char *qp = SvPV_const(query, ql);
867 1166 oq = oa_parse_query(aTHX_ o, qp, ql);
868 } else {
869 3132 oq = newHV();
870 }
871 5002 ▶ for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_QUERY]; i++) { 696 4306 5002
872 696 oa_param *pp = &o->params[OA_IN_QUERY][i];
873 696 STRLEN nl; const char *np = SvPV_const(pp->name, nl);
874 696 SV **v = hv_fetch(oq, np, (I32)nl, 0);
875 696 ▶ if (v && *v && SvOK(*v)) {
Branch: 3 branches
BranchTrueFalseTotal
if (v && *v && SvOK(*v)) { 574 122 696
if (v && *v && SvOK(*v)) { 574 0 574
if (v && *v && SvOK(*v)) { 574 0 574
876 /* present and empty, with allowEmptyValue: permitted as it
877 * stands rather than handed to a schema that will refuse it */
878 574 ▶ if (pp->allow_empty && !SvROK(*v) && SvCUR(*v) == 0) {
Branch: 3 branches
BranchTrueFalseTotal
if (pp->allow_empty && !SvROK(*v) && SvCUR(*v) == 0) { 3 571 574
if (pp->allow_empty && !SvROK(*v) && SvCUR(*v) == 0) { 3 0 3
if (pp->allow_empty && !SvROK(*v) && SvCUR(*v) == 0) { 2 1 3
879 /* accepted */
880 }
881 572 ▶ else if (!oa_check_param(aTHX_ pp, *v, errs, "query")) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
else if (!oa_check_param(aTHX_ pp, *v, errs, "query")) ok = 0; 11 561 572
882 122 ▶ } else if (pp->required) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (pp->required) { 5 117 122
883 5 ok = 0;
884 5 ▶ if (errs) oa_err_push(aTHX_ errs, "query", pp->name,
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "query", pp->name, 5 0 5
885 "required", "missing required query parameter");
886 }
887 696 ▶ if (!ok && !errs) goto done;
Branch: 2 branches
BranchTrueFalseTotal
if (!ok && !errs) goto done; 30 666 696
if (!ok && !errs) goto done; 0 30 30
888 }
889  
890 /* headers: declared names looked up lowercased */
891 6473 ▶ for (i = 0; i < o->nparams[OA_IN_HEADER]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_HEADER]; i++) { 2167 4306 6473
892 2167 oa_param *pp = &o->params[OA_IN_HEADER][i];
893 2167 STRLEN nl; const char *np = SvPV_const(pp->name, nl);
894 char lc[128];
895 2167 SV **v = NULL;
896 2167 ▶ if (nl < sizeof lc) {
Branch: 1 branch
BranchTrueFalseTotal
if (nl < sizeof lc) { 2167 0 2167
897 STRLEN k;
898 27953 ▶ for (k = 0; k < nl; k++) lc[k] = (char)toLOWER((U8)np[k]);
Branch: 2 branches
BranchTrueFalseTotal
for (k = 0; k < nl; k++) lc[k] = (char)toLOWER((U8)np[k]); 6453 19333 25786
for (k = 0; k < nl; k++) lc[k] = (char)toLOWER((U8)np[k]); 25786 2167 27953
899 2167 ▶ v = headers ? hv_fetch(headers, lc, (I32)nl, 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
v = headers ? hv_fetch(headers, lc, (I32)nl, 0) : NULL; 564 1603 2167
900 }
901 2195 ▶ if (v && *v && SvOK(*v)) {
Branch: 3 branches
BranchTrueFalseTotal
if (v && *v && SvOK(*v)) { 28 2139 2167
if (v && *v && SvOK(*v)) { 28 0 28
if (v && *v && SvOK(*v)) { 28 0 28
902 28 SV *val = *v;
903 /* header is always `simple`: a list is comma separated, and the
904 * value is not percent-encoded, so it is split but not decoded */
905 28 ▶ if (pp->is_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (pp->is_array) { 5 23 28
906 5 STRLEN hl; const char *hp = SvPV_const(val, hl);
907 5 val = sv_2mortal(oa_split(aTHX_ hp, hl, ',', 0, 0));
908 }
909 /* an object is comma separated too, and explode decides whether
910 * the pieces are `k,v` pairs or their own `k=v` */
911 23 ▶ else if (pp->is_object) {
Branch: 1 branch
BranchTrueFalseTotal
else if (pp->is_object) { 2 21 23
912 2 STRLEN hl; const char *hp = SvPV_const(val, hl);
913 2 SV *pieces = sv_2mortal(oa_split(aTHX_ hp, hl, ',', 0, 0));
914 2 val = pp->explode ? oa_obj_from_kv(aTHX_ pieces)
915 2 ▶ : oa_obj_from_pairs(aTHX_ pieces);
Branch: 1 branch
BranchTrueFalseTotal
: oa_obj_from_pairs(aTHX_ pieces); 1 1 2
916 }
917 28 ▶ if (!oa_check_param(aTHX_ pp, val, errs, "header")) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check_param(aTHX_ pp, val, errs, "header")) ok = 0; 3 25 28
918 25 else (void)hv_store(oh, np, (I32)nl, newSVsv(val), 0);
919 2139 ▶ } else if (pp->required) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (pp->required) { 2 2137 2139
920 2 ok = 0;
921 2 ▶ if (errs) oa_err_push(aTHX_ errs, "header", pp->name,
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "header", pp->name, 2 0 2
922 "required", "missing required header");
923 }
924 2167 ▶ if (!ok && !errs) goto done;
Branch: 2 branches
BranchTrueFalseTotal
if (!ok && !errs) goto done; 516 1651 2167
if (!ok && !errs) goto done; 0 516 516
925 }
926  
927 /* cookies: parsed from the Cookie header only when declared */
928 4306 ▶ if (o->nparams[OA_IN_COOKIE]) {
Branch: 1 branch
BranchTrueFalseTotal
if (o->nparams[OA_IN_COOKIE]) { 17 4289 4306
929 17 ▶ SV **ch = headers ? hv_fetchs(headers, "cookie", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV **ch = headers ? hv_fetchs(headers, "cookie", 0) : NULL; 16 1 17
930 17 HV *jar = NULL;
931 17 ▶ if (ch && *ch && SvOK(*ch)) {
Branch: 3 branches
BranchTrueFalseTotal
if (ch && *ch && SvOK(*ch)) { 16 1 17
if (ch && *ch && SvOK(*ch)) { 16 0 16
if (ch && *ch && SvOK(*ch)) { 16 0 16
932 16 STRLEN cl; const char *cp = SvPV_const(*ch, cl);
933 16 jar = oa_parse_cookies(aTHX_ cp, cl);
934 }
935 34 ▶ for (i = 0; i < o->nparams[OA_IN_COOKIE]; i++) {
Branch: 1 branch
BranchTrueFalseTotal
for (i = 0; i < o->nparams[OA_IN_COOKIE]; i++) { 17 17 34
936 17 oa_param *pp = &o->params[OA_IN_COOKIE][i];
937 17 STRLEN nl; const char *np = SvPV_const(pp->name, nl);
938 17 ▶ SV **v = jar ? hv_fetch(jar, np, (I32)nl, 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV **v = jar ? hv_fetch(jar, np, (I32)nl, 0) : NULL; 16 1 17
939 33 ▶ if (v && *v && SvOK(*v)) {
Branch: 3 branches
BranchTrueFalseTotal
if (v && *v && SvOK(*v)) { 16 1 17
if (v && *v && SvOK(*v)) { 16 0 16
if (v && *v && SvOK(*v)) { 16 0 16
940 16 SV *val = *v;
941 /* cookie is `form`; a list is comma separated. Values are
942 * kept raw by oa_parse_cookies, so split without decoding */
943 16 ▶ if (pp->is_array) {
Branch: 1 branch
BranchTrueFalseTotal
if (pp->is_array) { 2 14 16
944 2 STRLEN cl2; const char *cp2 = SvPV_const(val, cl2);
945 2 val = sv_2mortal(oa_split(aTHX_ cp2, cl2, ',', 0, 0));
946 }
947 /* an object cookie is assembled the way a header one is:
948 * comma separated, `k,v` pairs or `k=v` when exploded */
949 14 ▶ else if (pp->is_object) {
Branch: 1 branch
BranchTrueFalseTotal
else if (pp->is_object) { 0 14 14
950 0 STRLEN cl2; const char *cp2 = SvPV_const(val, cl2);
951 0 SV *pieces = sv_2mortal(oa_split(aTHX_ cp2, cl2, ',', 0, 0));
952 0 val = pp->explode ? oa_obj_from_kv(aTHX_ pieces)
953 0 ▶ : oa_obj_from_pairs(aTHX_ pieces);
Branch: 1 branch
BranchTrueFalseTotal
: oa_obj_from_pairs(aTHX_ pieces); 0 0 0
954 }
955 16 ▶ if (!oa_check_param(aTHX_ pp, val, errs, "cookie")) ok = 0;
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check_param(aTHX_ pp, val, errs, "cookie")) ok = 0; 1 15 16
956 15 else (void)hv_store(oc, np, (I32)nl, newSVsv(val), 0);
957 1 ▶ } else if (pp->required) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (pp->required) { 1 0 1
958 1 ok = 0;
959 1 ▶ if (errs) oa_err_push(aTHX_ errs, "cookie", pp->name,
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "cookie", pp->name, 1 0 1
960 "required", "missing required cookie");
961 }
962 17 ▶ if (!ok && !errs) { if (jar) SvREFCNT_dec((SV *)jar); goto done; }
Branch: 3 branches
BranchTrueFalseTotal
if (!ok && !errs) { if (jar) SvREFCNT_dec((SV *)jar); goto done; } 2 15 17
if (!ok && !errs) { if (jar) SvREFCNT_dec((SV *)jar); goto done; } 0 2 2
if (!ok && !errs) { if (jar) SvREFCNT_dec((SV *)jar); goto done; } 0 0 0
963 }
964 17 ▶ if (jar) SvREFCNT_dec((SV *)jar);
Branch: 1 branch
BranchTrueFalseTotal
if (jar) SvREFCNT_dec((SV *)jar); 16 1 17
965 }
966  
967 /* body */
968 4306 ▶ if (o->nbodies) {
Branch: 1 branch
BranchTrueFalseTotal
if (o->nbodies) { 2348 1958 4306
969 1958 ▶ SV **cth = headers ? hv_fetchs(headers, "content-type", 0) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
SV **cth = headers ? hv_fetchs(headers, "content-type", 0) : NULL; 1954 4 1958
970 1954 ▶ int have = body_raw && SvOK(body_raw)
Branch: 1 branch
BranchTrueFalseTotal
int have = body_raw && SvOK(body_raw) 1954 0 1954
971 3912 ▶ && (SvROK(body_raw) || SvCUR(body_raw) > 0);
Branch: 3 branches
BranchTrueFalseTotal
&& (SvROK(body_raw) || SvCUR(body_raw) > 0); 1954 4 1958
&& (SvROK(body_raw) || SvCUR(body_raw) > 0); 1929 25 1954
&& (SvROK(body_raw) || SvCUR(body_raw) > 0); 1929 0 1929
972 1958 ▶ if (!have) {
Branch: 1 branch
BranchTrueFalseTotal
if (!have) { 4 1954 1958
973 4 ▶ if (o->body_required) {
Branch: 1 branch
BranchTrueFalseTotal
if (o->body_required) { 4 0 4
974 4 ok = 0;
975 4 ▶ if (errs) oa_err_push(aTHX_ errs, "body", NULL,
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "body", NULL, 4 0 4
976 "required", "missing required request body");
977 }
978 } else {
979 1954 ▶ oa_body *b = oa_body_for(aTHX_ o, cth ? *cth : NULL);
Branch: 1 branch
BranchTrueFalseTotal
oa_body *b = oa_body_for(aTHX_ o, cth ? *cth : NULL); 1953 1 1954
980 1954 ▶ if (!b) {
Branch: 1 branch
BranchTrueFalseTotal
if (!b) { 3 1951 1954
981 3 ok = 0;
982 3 ▶ if (errs) oa_err_push(aTHX_ errs, "body", NULL, "content-type",
Branch: 1 branch
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "body", NULL, "content-type", 3 0 3
983 "undeclared request content type");
984 1951 ▶ } else if (b->handle) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (b->handle) { 1949 2 1951
985 /* A range declares no decoder of its own, so the REQUEST's
986 * content type decides. Without this a catch-all range would
987 * match and then pass through unvalidated - a silent
988 * acceptance, worse than the wrong rejection it replaced. */
989 1949 STRLEN ctl = 0;
990 1949 ▶ const char *ctp = (cth && *cth && SvOK(*cth))
Branch: 2 branches
BranchTrueFalseTotal
const char *ctp = (cth && *cth && SvOK(*cth)) 1949 0 1949
const char *ctp = (cth && *cth && SvOK(*cth)) 1949 0 1949
991 5847 ▶ ? SvPV_const(*cth, ctl) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
? SvPV_const(*cth, ctl) : NULL; 1949 0 1949
992 1949 int kind = b->kind;
993 SV *data;
994 /* a JSON body that decoded cleanly to the document `null`:
995 * data is NULL but nothing is wrong with it */
996 1949 int json_null = 0;
997 1949 HV *part_hdrs = NULL; /* multipart, when an encoding asks */
998 1949 ▶ if (kind == OA_MT_RANGE)
Branch: 1 branch
BranchTrueFalseTotal
if (kind == OA_MT_RANGE) 3 1946 1949
999 3 ▶ kind = ctp ? oa_ctype_kind(ctp, ctl) : OA_MT_OPAQUE;
Branch: 1 branch
BranchTrueFalseTotal
kind = ctp ? oa_ctype_kind(ctp, ctl) : OA_MT_OPAQUE; 3 0 3
1000  
1001 1949 ▶ if (SvROK(body_raw)) data = body_raw;
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(body_raw)) data = body_raw; 24 1925 1949
1002 1925 ▶ else if (kind == OA_MT_FORM)
Branch: 1 branch
BranchTrueFalseTotal
else if (kind == OA_MT_FORM) 17 1908 1925
1003 17 data = oa_form_decode(aTHX_ body_raw, b->encoding);
1004 1908 ▶ else if (kind == OA_MT_MULTIPART) {
Branch: 1 branch
BranchTrueFalseTotal
else if (kind == OA_MT_MULTIPART) { 8 1900 1908
1005 8 ▶ if (b->encoding)
Branch: 1 branch
BranchTrueFalseTotal
if (b->encoding) 4 4 8
1006 4 part_hdrs = (HV *)sv_2mortal((SV *)newHV());
1007 8 data = ctp ? oa_multipart_decode(aTHX_ body_raw, ctp, ctl,
1008 8 ▶ part_hdrs) : NULL;
Branch: 1 branch
BranchTrueFalseTotal
part_hdrs) : NULL; 8 0 8
1009 }
1010 1900 ▶ else if (kind == OA_MT_JSON) {
Branch: 1 branch
BranchTrueFalseTotal
else if (kind == OA_MT_JSON) { 1900 0 1900
1011 int dec_ok;
1012 1900 data = oa_body_decode_ok(aTHX_ body_raw, &dec_ok);
1013 1900 ▶ json_null = dec_ok && !data;
Branch: 2 branches
BranchTrueFalseTotal
json_null = dec_ok && !data; 1899 1 1900
json_null = dec_ok && !data; 68 1831 1899
1014 }
1015 else {
1016 /* a range covering something we cannot decode: preserve
1017 * the pass-through rather than invent a verdict */
1018 0 (void)hv_stores(out, "body", newSVsv(body_raw));
1019 0 goto body_done;
1020 }
1021  
1022 /* the Encoding Object, once the body IS properties */
1023 1949 ▶ if (data && b->encoding) {
Branch: 2 branches
BranchTrueFalseTotal
if (data && b->encoding) { 1880 69 1949
if (data && b->encoding) { 13 1867 1880
1024 13 oa_apply_encoding(aTHX_ data, b->encoding);
1025 13 ▶ if (!oa_check_encoding_headers(aTHX_ b->encoding,
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check_encoding_headers(aTHX_ b->encoding, 2 11 13
1026 part_hdrs, errs))
1027 2 ok = 0;
1028 }
1029  
1030 1949 ▶ if (!data && json_null) {
Branch: 2 branches
BranchTrueFalseTotal
if (!data && json_null) { 69 1880 1949
if (!data && json_null) { 68 1 69
1031 /* the document IS null. Hand the schema an undef so it can
1032 * say whether `null` was allowed here, rather than calling
1033 * a well-formed body malformed. */
1034 108 ▶ if (!oa_check(aTHX_ b->handle, &PL_sv_undef, errs,
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check(aTHX_ b->handle, &PL_sv_undef, errs, 40 28 68
1035 "body", NULL))
1036 40 ok = 0;
1037 1881 ▶ } else if (!data) {
Branch: 1 branch
BranchTrueFalseTotal
} else if (!data) { 1 1880 1881
1038 1 ok = 0;
1039 1 ▶ if (errs) oa_err_push(aTHX_ errs, "body", NULL,
Branch: 3 branches
BranchTrueFalseTotal
if (errs) oa_err_push(aTHX_ errs, "body", NULL, 1 0 1
if (errs) oa_err_push(aTHX_ errs, "body", NULL, 0 1 1
if (errs) oa_err_push(aTHX_ errs, "body", NULL, 0 1 1
1040 kind == OA_MT_MULTIPART ? "multipart" : "json",
1041 kind == OA_MT_MULTIPART
1042 ? "request body is not valid multipart/form-data"
1043 : "request body is not valid JSON");
1044 } else {
1045 1880 ▶ if (!oa_check(aTHX_ b->handle, data, errs, "body", NULL))
Branch: 1 branch
BranchTrueFalseTotal
if (!oa_check(aTHX_ b->handle, data, errs, "body", NULL)) 709 1171 1880
1046 709 ok = 0;
1047 1171 else (void)hv_stores(out, "body", newSVsv(data));
1048 }
1049 } else {
1050 2 (void)hv_stores(out, "body", newSVsv(body_raw)); /* pass-through */
1051 }
1052 }
1053 1958 body_done:
1054 1958 ▶ if (!ok && !errs) goto done;
Branch: 2 branches
BranchTrueFalseTotal
if (!ok && !errs) goto done; 1199 759 1958
if (!ok && !errs) goto done; 759 0 759
1055 }
1056  
1057 4306 done:
1058 4306 ▶ if (ok && params_out) {
Branch: 2 branches
BranchTrueFalseTotal
if (ok && params_out) { 3016 1290 4306
if (ok && params_out) { 3016 0 3016
1059 3016 (void)hv_stores(out, "path", newRV_noinc((SV *)op_));
1060 3016 ▶ (void)hv_stores(out, "query", newRV_noinc((SV *)(oq ? oq : newHV())));
Branch: 1 branch
BranchTrueFalseTotal
(void)hv_stores(out, "query", newRV_noinc((SV *)(oq ? oq : newHV()))); 0 3016 3016
1061 3016 (void)hv_stores(out, "header", newRV_noinc((SV *)oh));
1062 3016 (void)hv_stores(out, "cookie", newRV_noinc((SV *)oc));
1063 3016 *params_out = out;
1064 } else {
1065 1290 SvREFCNT_dec((SV *)op_);
1066 1290 ▶ if (oq) SvREFCNT_dec((SV *)oq);
Branch: 1 branch
BranchTrueFalseTotal
if (oq) SvREFCNT_dec((SV *)oq); 1290 0 1290
1067 1290 SvREFCNT_dec((SV *)oh);
1068 1290 SvREFCNT_dec((SV *)oc);
1069 1290 SvREFCNT_dec((SV *)out);
1070 1290 ▶ if (params_out) *params_out = NULL;
Branch: 1 branch
BranchTrueFalseTotal
if (params_out) *params_out = NULL; 1290 0 1290
1071 }
1072 4306 return ok;
1073 }
1074  
1075 #endif /* OA_VALIDATE_H */
« include/oa_tools.h ↑ Summary include/oa_types.h »