mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 11:16:33 +03:00
Makes the build system to look for yajl using a macro file
Now searching for yajl using find_yajl.m4 macro file instead of using pkg-config directly. If YAJL was not found or if it was disabled in the configure phase, the code will be compiled without JSON support.
This commit is contained in:
committed by
Felipe Zimmerle
parent
e90874a694
commit
8d4c3e4f5c
@@ -128,12 +128,19 @@ apr_status_t modsecurity_request_body_start(modsec_rec *msr, char **error_msg) {
|
||||
}
|
||||
}
|
||||
else if (strcmp(msr->msc_reqbody_processor, "JSON") == 0) {
|
||||
#ifdef WITH_YAJL
|
||||
if (json_init(msr, &my_error_msg) < 0) {
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON parsing error (init): %s", my_error_msg);
|
||||
msr->msc_reqbody_error = 1;
|
||||
msr->msc_reqbody_error_msg = my_error_msg;
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
}
|
||||
#else
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON support was not enabled");
|
||||
msr->msc_reqbody_error = 1;
|
||||
msr->msc_reqbody_error_msg = my_error_msg;
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
#endif
|
||||
}
|
||||
else if (strcmp(msr->msc_reqbody_processor, "URLENCODED") == 0) {
|
||||
/* Do nothing, URLENCODED processor does not support streaming yet. */
|
||||
@@ -356,13 +363,20 @@ apr_status_t modsecurity_request_body_store(modsec_rec *msr,
|
||||
/* Increase per-request data length counter. */
|
||||
msr->msc_reqbody_no_files_length += length;
|
||||
|
||||
/* Process data as XML. */
|
||||
/* Process data as JSON. */
|
||||
#ifdef WITH_YAJL
|
||||
if (json_process_chunk(msr, data, length, &my_error_msg) < 0) {
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON parsing error: %s", my_error_msg);
|
||||
msr->msc_reqbody_error = 1;
|
||||
msr->msc_reqbody_error_msg = *error_msg;
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
}
|
||||
#else
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON support was not enabled");
|
||||
msr->msc_reqbody_error = 1;
|
||||
msr->msc_reqbody_error_msg = *error_msg;
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
#endif
|
||||
}
|
||||
else if (strcmp(msr->msc_reqbody_processor, "URLENCODED") == 0) {
|
||||
/* Increase per-request data length counter. */
|
||||
@@ -622,6 +636,7 @@ apr_status_t modsecurity_request_body_end(modsec_rec *msr, char **error_msg) {
|
||||
}
|
||||
}
|
||||
else if (strcmp(msr->msc_reqbody_processor, "JSON") == 0) {
|
||||
#ifdef WITH_YAJL
|
||||
if (json_complete(msr, &my_error_msg) < 0) {
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON parser error: %s", my_error_msg);
|
||||
msr->msc_reqbody_error = 1;
|
||||
@@ -629,6 +644,14 @@ apr_status_t modsecurity_request_body_end(modsec_rec *msr, char **error_msg) {
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
*error_msg = apr_psprintf(msr->mp, "JSON support was not enabled");
|
||||
msr->msc_reqbody_error = 1;
|
||||
msr->msc_reqbody_error_msg = *error_msg;
|
||||
msr_log(msr, 2, "%s", *error_msg);
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (strcmp(msr->msc_reqbody_processor, "URLENCODED") == 0) {
|
||||
return modsecurity_request_body_end_urlencoded(msr, error_msg);
|
||||
|
Reference in New Issue
Block a user