Bug 11793 - Parse error in ExtFilterDefine
Summary: Parse error in ExtFilterDefine
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_ext_filter (show other bugs)
Version: 2.0.40
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
: 11794 (view as bug list)
Depends on:
Reported: 2002-08-17 18:04 UTC by Sebastian Wolfgarten
Modified: 2004-11-16 19:05 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Wolfgarten 2002-08-17 18:04:28 UTC

I'm currently playing with output
filters. I thought of using awk
to print out the number
of each line. In my bash shell I
used this:

echo "<html>" | awk '{print NR ":" $N}'

I add the following lines to my httpd.conf:

ExtFilterDefine awk_line_numbering mode=output outtype=text/html 
cmd="/bin/awk '{print NR\": \" $N}'" 
<Location /> 
SetOutputFilter awk_line_numbering 

Now when I start the apache I get a
syntax error. 

Unexpected parameter: `: \" $N}'"'

I suppose this is a bug because some
external programs like awk need to use
quotation marks in order to work.
A workaround is to put the awk command in
an extra shell script but I assume
this to be a bug.

My friend Werner Schalk has already posted
this to the users mailing list of apache but
they said I should use back-slashes (what I
did anyway) or to report a bug. Here it is :-)

Bye and thanks,
Sebastian Wolfgarten
Comment 1 William A. Rowe Jr. 2002-08-18 20:01:48 UTC
Did you try
  ExtFilterDefine awk_line_numbering mode=output outtype=text/html 
     cmd="/bin/awk '{print NR\\\": \\\" $N}'"

In case the '\' escaping is eating the second double quote?

If that's not the workaround, there is a bug in the parser.
Comment 2 Paul J. Reder 2002-08-19 16:26:00 UTC
This indeed seems to be a bug. parse_cmd in mod_ext_filter.c does not process
escaping characters. It sees the first " and scans till it finds the next ". No
checks for escape chars.

I'll have a fix shortly.
Comment 3 Christoph Vogel 2002-08-19 20:44:38 UTC
If you need a line numbering ExtFilter urgently you can use pr without getting 
into escaping issues:

ExtFilterDefine pr_line_numbering cmd="/usr/bin/pr -n -t"
Comment 4 Jeff Trawick 2002-08-21 19:57:22 UTC
This was fixed earlier today (go Paul!).  I just verified that this 
cmd= parameter yields a filter that prefixes the response with line 

cmd="/bin/awk '{print NR\": \" $N}'"

To pick up the fix, you need a new modules/experimental/mod_ext_filter.c 
and a new srclib/apr/strings/apr_cpystrn.c.  This will all be in the 
next release of Apache 2.0.x.

Thanks for your report, and thanks for using Apache.
Comment 5 Jeff Trawick 2002-08-21 20:19:58 UTC
*** Bug 11794 has been marked as a duplicate of this bug. ***