Re: RubyInputFilter/RubyOutputFilter patch
Shugo Maeda <[email protected]> Sat, 07 Jan 2006 21:07:33 +0900
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
Hi, Thanks for your patch. At 12/28/05 00:58:16 (JST), why the lucky stiff <[email protected]> wrote: > In httpd.conf: > > RubyRequire filter_test > RubyOutputFilter FilterTest.instance TEST > SetOutputFilter TEST > > In lib/filter_test.rb > > require 'singleton' > > class FilterTest > include Singleton > > def output_filter(filter) > s = filter.read > while s > filter.write s.gsub(/mod_python/i, 'mod_ruby') > s = filter.read > end > > filter.close if filter.eos? > end > end It looks good, but I couldn't run it successfully:( I changed rb_filter_write() to avoid SEGV: --- apache_filter.c.orig 2006-01-07 21:00:28.270789288 +0900 +++ apache_filter.c 2006-01-07 21:01:22.904483704 +0900 @@ -269,22 +271,19 @@ apr_bucket *b; ApacheFilter *filter = get_filter_data(self); conn_rec *c = filter->req->connection; - VALUE tmp, port; - int taint; + VALUE tmp; if (NIL_P(tmp = rb_check_string_type(s))) { rb_raise(rb_eTypeError, "Argument to write() must be a string"); return Qnil; } - taint = OBJ_TAINTED(port); /* original taintedness */ - port = tmp; if (filter->closed) { rb_raise(rb_eTypeError, "I/O operation on closed filter"); return Qnil; } - len = RSTRING(s)->len; + len = RSTRING(tmp)->len; if (len) { @@ -295,7 +294,7 @@ } buff = apr_bucket_alloc(len, c->bucket_alloc); - memcpy(buff, RSTRING(s)->ptr, len); + memcpy(buff, RSTRING(tmp)->ptr, len); b = apr_bucket_heap_create(buff, len, apr_bucket_free, c->bucket_alloc); But it seems that mod_ruby goes into infinite loop.... Does it work on your machine, why? Shugo