Fix email validation

This commit is contained in:
2019-04-25 15:04:45 +02:00
parent e3e84a0441
commit e623c0dce1
2 changed files with 26 additions and 4 deletions
+21 -3
View File
@@ -34,6 +34,8 @@ struct context
typedef struct context * Context;
static const char modName[] = "feedback";
static void
context_free(Context ctx)
@@ -128,13 +130,24 @@ on_stream_input(AxFeedback mod, const struct aisl_evt_input *evt)
static AislStatus
on_stream_request(AxFeedback mod, const struct aisl_evt *evt)
{
int rc;
Context ctx = aisl_get_context((AislStream)evt->source);
AislStream s = (AislStream)evt->source;
/* verify input */
if (!ctx->email || !ctx->msg || ax_validate_email(ctx->email) != 0) {
ax_quick_response(s, AISL_HTTP_BAD_REQUEST);
goto finally;
if (!ctx->email) {
AX_LOG_ALERT("%s: email empty", modName);
goto bad_request;
}
if (!ctx->msg) {
AX_LOG_ALERT("%s: msg empty", modName);
goto bad_request;
}
if ((rc = ax_validate_email(ctx->email))!= 0) {
AX_LOG_ALERT("%s: invalid email at %d", modName, rc);
goto bad_request;
}
ctx->mail.reply_to = ctx->email;
@@ -146,6 +159,11 @@ on_stream_request(AxFeedback mod, const struct aisl_evt *evt)
aisl_set_output_event(s, true); /**< enable output event */
goto finally;
bad_request:
ax_quick_response(s, AISL_HTTP_BAD_REQUEST);
finally:
return AISL_SUCCESS;
}