You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by fr...@friedo.com on 2003/09/14 09:07:37 UTC

[PATCH] Query string parsing for mod_include.c, Part 2

Hello again.

Attached is an updated version of my mod_include patch to add query string
parsing. (See original thread here:
http://www.mail-archive.com/dev%40httpd.apache.org/msg17657.html)

This works with the current 2.1 branch in CVS and implements a number of
the suggestions from the first thread:

1. This is a seperate module, mod_include_query.c, which hooks into
mod_include via the ap_register_include_handler optional function. So this
isn't technically a patch, it's a new file. :)

2. Adds support for query strings delimited by semicolon (;).

3. Adds a bit of namespace protection by prepending all query string
variables with a leading underscore (_). This prevents someone from using
this feature to override important environment variables, unless you begin
your important environment variables with an underscore.

4. Adds support for variables with multiple values. So a query string like

    ?multi=one&multi=two&multi=three&foo=bar

will generate the following variables:

_multi = one,two,three
_multi[0] = one
_multi[1] = two
_multi[2] = three
_foo = bar
_foo[0] = bar

The disadvantage is that single variables will be getting added to the
table twice, as _foo and _foo[0] demonstrate. Since the number of
variables on a query string is generally small, I don't see this as a big
problem. However, we may want to add an ability to turn multiple
processing off. I'm not sure how this would be implimented yet (is
mod_include's #config handler hookable in any way? If not, perhaps I could
add a hook mechanism to it.)

Mr. André Malo also suggested modifying #set to access query string vars,
but again I don't know if this is possible without mucking about in
mod_include.c itself. I will investigate creating a hooking mechanism for
existing directives, because that would be cool if it can be done.

mod_include_query.c is attached. To enable it you'll have to add it to
modules/filters/config.m4:

APACHE_MODULE(include_query, SSI query string extensions, , , yes)

Feedback is welcomed, of course. Enjoy!

--
Mike Friedman