summaryrefslogtreecommitdiff
path: root/docs/manual/mod/mod_sed.xml
blob: 898b73edfd418b6c3198f97904747f0735412291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?xml version="1.0"?>
<!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
<?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
<!-- $LastChangedRevision$ -->

<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<modulesynopsis metafile="mod_sed.xml.meta">

<name>mod_sed</name>
<description>Filter Input (request) and Output (response) content using <code>sed</code> syntax</description>
<status>Experimental</status>
<sourcefile>mod_sed.c sed0.c sed1.c regexp.c regexp.h sed.h</sourcefile>
<identifier>sed_module</identifier>
<compatibility>Available in Apache 2.3 and later</compatibility>

<summary>
<p>
<module>mod_sed</module> is an in-process content filter. The <module>mod_sed</module> filter implements the <code>sed</code> editing
commands implemented by the Solaris 10 <code>sed</code>
program as described in the <a href="http://www.gnu.org/software/sed/manual/sed.txt">manual
page</a>. However, unlike <code>sed</code>, <module>mod_sed</module> doesn't take data from
standard
input. Instead, the filter acts on the entity data sent between client and
server. <module>mod_sed</module> can be used as an input or output filter. <module>mod_sed</module> is a
content filter, which means that it cannot be used to modify client or
server http headers.
</p>
<p>
The <module>mod_sed</module> output filter accepts a chunk of data, executes the <code>sed</code> scripts on the data, and generates the output which is passed to the next filter in the chain.
</p>

<p>
The <module>mod_sed</module> input filter reads the data from the next filter in the chain, executes the <code>sed</code> scripts, and returns the generated data to the caller filter in the filter chain.
</p>

<p>
Both the input and output filters only process the data if newline characters are seen in the content. At the end of the data, the rest of the data is treated as the last line.
</p>

</summary>

<section id="sampleconf"><title>Sample Configuration</title>
    <example><title>Adding an output filter </title>
    <highlight language="config">
# In the following example, the sed filter will change the string
# "monday" to "MON" and the string "sunday" to SUN in html documents
# before sending to the client.
&lt;Directory "/var/www/docs/sed"&gt;
    AddOutputFilter Sed html
    OutputSed "s/monday/MON/g"
    OutputSed "s/sunday/SUN/g"
&lt;/Directory&gt;
    </highlight>
    </example>

    <example><title>Adding an input filter </title>
    <highlight language="config">
# In the following example, the sed filter will change the string
# "monday" to "MON" and the string "sunday" to SUN in the POST data
# sent to PHP.
&lt;Directory "/var/www/docs/sed"&gt;
    AddInputFilter Sed php
    InputSed "s/monday/MON/g"
    InputSed "s/sunday/SUN/g"
&lt;/Directory&gt;
        </highlight>
    </example>
</section>
<section id="sed_commands"><title>Sed Commands</title>
    <p>
    Complete details of the <code>sed</code> command can be found from the
   <a href="http://www.gnu.org/software/sed/manual/sed.txt">sed manual
page</a>.
    </p>
    <dl>
        <dt><code>b</code></dt>
        <dd>Branch to the label specified (similar to goto).</dd>
        <dt><code>h</code></dt>
        <dd>Copy the current line to the hold buffer.</dd>
        <dt><code>H</code></dt>
        <dd>Append the current line to the hold buffer.</dd>
        <dt><code>g</code></dt>
        <dd>Copy the hold buffer to the current line.</dd>
        <dt><code>G</code></dt>
        <dd>Append the hold buffer to the current line.</dd>
        <dt><code>x</code></dt>
        <dd>Swap the contents of the hold buffer and the current line.</dd>
    </dl>
</section>

<directivesynopsis>
<name>OutputSed</name>
<description>Sed command for filtering response content</description>
<syntax>OutputSed <var>sed-command</var></syntax>
<contextlist><context>directory</context><context>.htaccess</context>
</contextlist>

<usage>
    <p>The <directive>OutputSed</directive> directive specifies the <code>sed</code>
    command to execute on the response.
    </p>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>InputSed</name>
<description>Sed command to filter request data (typically <code>POST</code> data)</description>
<syntax>InputSed <var>sed-command</var></syntax>
<contextlist><context>directory</context><context>.htaccess</context>
</contextlist>

<usage>
    <p>The <directive>InputSed</directive> directive specifies the <code>sed</code> command
    to execute on the request data e.g., <code>POST</code> data.
    </p>
</usage>
</directivesynopsis>

</modulesynopsis>