On 09/10/2008 05:54 AM, [EMAIL PROTECTED] wrote:
Author: ianh Date: Tue Sep 9 20:53:59 2008 New Revision: 693697 URL: http://svn.apache.org/viewvc?rev=693697&view=rev Log: initial check in. this filter validates that the incoming request contains valid UTF8 characters. Added: httpd/sandbox/mod_valid_utf8/ httpd/sandbox/mod_valid_utf8/README (with props) httpd/sandbox/mod_valid_utf8/mod_valid_utf8.c (with props)
Added: httpd/sandbox/mod_valid_utf8/mod_valid_utf8.c URL: http://svn.apache.org/viewvc/httpd/sandbox/mod_valid_utf8/mod_valid_utf8.c?rev=693697&view=auto ==============================================================================
+ +static apr_status_t utf8_in_filter(ap_filter_t *f, + apr_bucket_brigade *bb, + ap_input_mode_t mode, + apr_read_type_e block, + apr_off_t readbytes) { + apr_status_t rv; + utf8_ctx *ctx = f->ctx; + + if (!ctx) { + ctx = apr_pcalloc( f->c->pool, sizeof(*ctx)); + ctx->bb = apr_brigade_create( f->c->pool, f->c->bucket_alloc ); + } + rv = ap_get_brigade(f->next, ctx->bb, mode, block, readbytes); + if ( rv != APR_SUCCESS ) { + return rv; + } + + while ( !APR_BRIGADE_EMPTY(ctx->bb) ) { + apr_size_t length; + char *buffer; + const char *data; + apr_bucket *cpy; + int i ; + apr_bucket *b;+ + b = APR_BRIGADE_FIRST(ctx->bb );+ APR_BUCKET_REMOVE(b); + if ( APR_BUCKET_IS_EOS(b) ) { + APR_BRIGADE_INSERT_TAIL( bb, b); + break; + } + length = b->length; + + rv = apr_bucket_read( b, &data, &length, APR_BLOCK_READ); + if ( rv != APR_SUCCESS ) { + return rv; + } + + buffer = validate_buffer(f->c->pool, data, &length);
What do you do when a multibyte character is split over multiple buckets? Regards RĂ¼diger
