Removed some code that implemented SecRequestEncoding. Left the directive in, as well as the structure member as they are harmless.

This commit is contained in:
ivanr 2007-12-17 15:09:59 +00:00
parent b9a28882b2
commit dc081c5df1

View File

@ -306,87 +306,6 @@ void add_argument(modsec_rec *msr, apr_table_t *arguments, msc_arg *arg) {
arg->origin, log_escape_ex(msr->mp, arg->name, arg->name_len),
log_escape_ex(msr->mp, arg->value, arg->value_len));
#ifdef WITH_ICONV
if (msr->txcfg->request_encoding != NULL) {
iconv_t convset;
// TODO Convert parameter names too.
/* Initialise iconv. */
convset = iconv_open("ISO-8859-1", msr->txcfg->request_encoding);
if (convset == (iconv_t)(-1)) {
msr_log(msr, 1, "Iconv init to %s failed: %s",
msr->txcfg->request_encoding, strerror(errno));
} else {
int ctlparam = 1;
size_t input_bytes = arg->value_len;
size_t output_bytes = arg->value_len;
char *o, *outbuf;
// TODO Can output be longer than input?
// TODO We are currently using more memory than necessary
// as the parameter values before transformation are
// not freed after conversion.
o = outbuf = apr_palloc(msr->mp, output_bytes);
/* Tell iconv to reject invalid character sequences. */
iconvctl(convset, ICONV_SET_DISCARD_ILSEQ, &ctlparam);
/* Convert input character sequence. */
if (iconv(convset, (const char **)&arg->value,
(size_t *)&input_bytes,
(char **)&outbuf,
(size_t *)&output_bytes) == (size_t)(-1))
{
msr_log(msr, 1, "Error converting to %s: %s",
msr->txcfg->request_encoding, strerror(errno));
} else {
arg->value = o;
arg->value_len = arg->value_len - output_bytes;
msr_log(msr, 5, "Parameter value after conversion from %s: %s",
msr->txcfg->request_encoding,
log_escape_nq_ex(msr->mp, arg->value, arg->value_len));
}
iconv_close(convset);
}
}
#else
if (msr->txcfg->request_encoding != NULL) {
apr_xlate_t *convset = NULL;
int rc;
rc = apr_xlate_open(&convset, "ISO-8859-1", msr->txcfg->request_encoding, msr->mp);
if (rc != APR_SUCCESS) {
msr_log(msr, 1, "apr_xlate_open failed: %s", get_apr_error(msr->mp, rc));
} else {
apr_size_t input_bytes = arg->value_len;
apr_size_t output_bytes = arg->value_len;
char *o, *outbuf;
o = outbuf = apr_palloc(msr->mp, output_bytes);
rc = apr_xlate_conv_buffer(convset, arg->value, &input_bytes, outbuf, &output_bytes);
if (rc != APR_SUCCESS) {
msr_log(msr, 1, "Error converting to %s: %s",
msr->txcfg->request_encoding, get_apr_error(msr->mp, rc));
} else {
apr_xlate_conv_buffer(convset, NULL, NULL, outbuf, &output_bytes);
arg->value = o;
arg->value_len = arg->value_len - output_bytes;
msr_log(msr, 5, "Parameter value after conversion from %s: %s",
msr->txcfg->request_encoding,
log_escape_nq_ex(msr->mp, arg->value, arg->value_len));
}
apr_xlate_close(convset);
}
}
#endif
apr_table_addn(arguments, arg->name, (void *)arg);
}