refactors http card validation

in u3_http_ef_that and u3_http_ef_form
This commit is contained in:
Joe Bryan 2018-09-28 21:44:04 -04:00
parent 34570e428e
commit 8affdf44ea

View File

@ -1501,15 +1501,26 @@ _http_form_free(void)
void void
u3_http_ef_form(u3_noun fig) u3_http_ef_form(u3_noun fig)
{ {
// XX validate / test axes? u3_noun sec, pro, log, red;
u3_noun sec = u3h(fig);
u3_noun lob = u3t(fig); if ( (c3n == u3r_qual(fig, &sec, &pro, &log, &red) ) ||
// confirm sec is a valid (unit ^)
!( u3_nul == sec || ( c3y == u3du(sec) &&
c3y == u3du(u3t(sec)) &&
u3_nul == u3h(sec) ) ) ||
// confirm valid flags ("loobeans")
!( c3y == pro || c3n == pro ) ||
!( c3y == log || c3n == log ) ||
!( c3y == red || c3n == red ) ) {
uL(fprintf(uH, "http: form: invalid card\n"));
u3z(fig);
return;
}
u3_form* for_u = c3_malloc(sizeof(*for_u)); u3_form* for_u = c3_malloc(sizeof(*for_u));
for_u->pro = (c3_o)pro;
for_u->pro = (c3_o)u3h(lob); for_u->log = (c3_o)log;
for_u->log = (c3_o)u3h(u3t(lob)); for_u->red = (c3_o)red;
for_u->red = (c3_o)u3t(u3t(lob));
if ( u3_nul != sec ) { if ( u3_nul != sec ) {
u3_noun key = u3h(u3t(sec)); u3_noun key = u3h(u3t(sec));
@ -2813,15 +2824,13 @@ _proxy_serv_start(u3_prox* lis_u)
void void
u3_http_ef_that(u3_noun tat) u3_http_ef_that(u3_noun tat)
{ {
u3_noun sip = u3h(tat); u3_noun sip, por, sec, non;
u3_noun por = u3h(u3t(tat));
u3_noun sec = u3h(u3t(u3t(tat)));
u3_noun non = u3t(u3t(u3t(tat)));
if( c3n == u3ud(sip) || if ( ( c3n == u3r_qual(tat, &sip, &por, &sec, &non) ) ||
c3n == u3a_is_cat(por) || ( c3n == u3ud(sip) ) ||
( c3n == u3a_is_cat(por) ) ||
!( c3y == sec || c3n == sec ) || !( c3y == sec || c3n == sec ) ||
c3n == u3ud(non) ) { ( c3n == u3ud(non) ) ) {
uL(fprintf(uH, "http: that: invalid card\n")); uL(fprintf(uH, "http: that: invalid card\n"));
u3z(tat); u3z(tat);
return; return;