Fix email validation
This commit is contained in:
+21
-3
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user