Commit 5a984846 authored by Stefan Fritsch's avatar Stefan Fritsch
Browse files

Use the new "ap_expr" expression parser.

The old parser can still be used by setting the new directive
SSILegacyExprParser


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1128614 13f79535-47bb-0310-9956-ffa450edef68
parent 9a599ad0
Loading
Loading
Loading
Loading
+4 −0
Changes for CHANGES: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@

Changes with Apache 2.3.13

  *) mod_include: Make the "#if expr" element use the new "ap_expr" expression
     parser. The old parser can still be used by setting the new directive
     SSILegacyExprParser. [Stefan Fritsch]

  *) core: Add some features to ap_expr for use by mod_include: a restricted
     mode that does not allow to bypass request access restrictions; new
     variables DOCUMENT_URI (alias for REQUEST_URI), LAST_MODIFIED; -A as an
+0 −2
Changes for STATUS: 0 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -96,8 +96,6 @@ RELEASE SHOWSTOPPERS:
    jim sez: Why a blocker?, pgollucci +1 jim
    wrowe asks: what's the API change required?

  * mod_includes aught to use ap_expr

  * Clarify/potentially change the meaning of MaxConnections for Event MPM 
    with respect to accepting new connections and keep alive requests for 
    the docs and example config.  This shouldn't change after users and 
+33 −26
Changes for docs/manual/expr.xml: 33 added lines, 26 removed lines.
Original line number Diff line number Diff line
@@ -354,48 +354,50 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
    <table border="1" style="zebra">
    <columnspec><column width=".2"/><column width=".2"/><column width=".6"/></columnspec>

    <tr><th>Name</th><th>Description</th></tr>
    <tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
    <tr><td><code>-d</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is a directory</td></tr>
            True if the file exists and is a directory</td><td>yes</td></tr>
    <tr><td><code>-e</code></td>
        <td>The argument is treated as a filename.
            True if the file (or dir or special) exists</td></tr>
            True if the file (or dir or special) exists</td><td>yes</td></tr>
    <tr><td><code>-f</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is regular file</td></tr>
            True if the file exists and is regular file</td><td>yes</td></tr>
    <tr><td><code>-L</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is symlink</td></tr>
            True if the file exists and is symlink</td><td>yes</td></tr>
    <tr><td><code>-h</code></td>
        <td>The argument is treated as a filename.
            True if the file exists and is symlink
            (same as <code>-L</code>)</td></tr>
            (same as <code>-L</code>)</td><td>yes</td></tr>
    <tr><td><code>-F</code></td>
        <td>True if string is a valid file, accessible via all the server's
            currently-configured access controls for that path. This uses an
            internal subrequest to do the check, so use it with care - it can
            impact your server's performance!</td></tr>
            impact your server's performance!</td><td></td></tr>
    <tr><td><code>-U</code></td>
        <td>True if string is a valid URL, accessible via all the server's
            currently-configured access controls for that path. This uses an
            internal subrequest to do the check, so use it with care - it can
            impact your server's performance!</td></tr>
            impact your server's performance!</td><td></td></tr>
    <tr><td><code>-A</code></td>
        <td>Alias for <code>-U</code></td></tr>
        <td>Alias for <code>-U</code></td><td></td></tr>
    <tr><td><code>-n</code></td>
        <td>True if string is not empty</td></tr>
        <td>True if string is not empty</td><td></td></tr>
    <tr><td><code>-z</code></td>
        <td>True if string is empty</td></tr>
        <td>True if string is empty</td><td></td></tr>
    <tr><td><code>-T</code></td>
        <td>False if string is empty, "<code>0</code>", "<code>off</code>",
            "<code>false</code>", or "<code>no</code>" (case insensitive).
            True otherwise.</td></tr>
            True otherwise.</td><td></td></tr>
    <tr><td><code>-R</code></td>
        <td>Same as "<code>%{REMOTE_ADDR} -ipmatch ...</code>", but more efficient
        </td></tr>
        </td><td></td></tr>
    </table>

    <p>The operators marked as "restricted" are not available in some modules
    like <module>mod_include</module>.</p>
</section>

<section id="functions">
@@ -408,35 +410,40 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
    <table border="1" style="zebra">
    <columnspec><column width=".2"/><column width=".8"/></columnspec>

    <tr><th>Name</th><th>Description</th></tr>
    <tr><th>Name</th><th>Description</th><th>Restricted</th></tr>
    <tr><td><code>req</code>, <code>http</code></td>
        <td>Get HTTP request header</td></tr>
        <td>Get HTTP request header</td><td></td></tr>
    <tr><td><code>resp</code></td>
        <td>Get HTTP response header</td></tr>
        <td>Get HTTP response header</td><td></td></tr>
    <tr><td><code>reqenv</code></td>
        <td>Lookup request environment variable</td></tr>
        <td>Lookup request environment variable</td><td></td></tr>
    <tr><td><code>osenv</code></td>
        <td>Lookup operating system environment variable</td></tr>
        <td>Lookup operating system environment variable</td><td></td></tr>
    <tr><td><code>note</code></td>
        <td>Lookup request note</td></tr>
        <td>Lookup request note</td><td></td></tr>
    <tr><td><code>env</code></td>
        <td>Return first match of <code>note</code>, <code>reqenv</code>,
            <code>osenv</code></td></tr>
            <code>osenv</code></td><td></td></tr>
    <tr><td><code>tolower</code></td>
        <td>Convert string to lower case</td></tr>
        <td>Convert string to lower case</td><td></td></tr>
    <tr><td><code>toupper</code></td>
        <td>Convert string to uppser case</td></tr>
        <td>Convert string to uppser case</td><td></td></tr>
    <tr><td><code>escape</code></td>
        <td>Escape special characters in %hex encoding</td></tr>
        <td>Escape special characters in %hex encoding</td><td></td></tr>
    <tr><td><code>unescape</code></td>
        <td>Unescape %hex encoded string, leaving URL-special characters encoded (XXX: describe better)</td></tr>
        <td>Unescape %hex encoded string, leaving URL-special characters
            encoded (XXX: describe better)</td><td></td></tr>
    <tr><td><code>file</code></td>
        <td>Read contents from a file</td></tr>
        <td>Read contents from a file</td><td>yes</td></tr>
    <tr><td><code>filesize</code></td>
        <td>Return size of a file (or 0 if file does not exist or is not regular file)</td></tr>
        <td>Return size of a file (or 0 if file does not exist or is not
            regular file)</td><td>yes</td></tr>

    </table>

    <p>The functions marked as "restricted" are not available in some modules
    like <module>mod_include</module>.</p>

    <p>In addition to string-valued functions, there are also list-valued functions which
    take one string as argument and return a wordlist, i.e. a list of strings. The wordlist
    can be used with the special <code>-in</code> operator.
+2 −1
Changes for docs/manual/howto/ssi.xml: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -448,7 +448,8 @@ modified?</title>
    <p>Then, in your SSI-enabled document, you might do the
    following:</p>
<example>
        &lt;!--#if expr="${Mac} &amp;&amp; ${InternetExplorer}" --&gt;<br />
        &lt;!--#if expr="-T reqenv('Mac') &amp;&amp;
                         -T reqenv('InternetExplorer')" --&gt;<br />
        Apologetic text goes here<br />
        &lt;!--#else --&gt;<br />
        Cool JavaScript code goes here<br />
+79 −31
Changes for docs/manual/mod/mod_include.xml: 79 added lines, 31 removed lines.
Original line number Diff line number Diff line
@@ -504,12 +504,14 @@
    directive. This includes the <code>config</code>,
    <code>exec</code>, <code>flastmod</code>, <code>fsize</code>,
    <code>include</code>, <code>echo</code>, and <code>set</code>
    directives, as well as the arguments to conditional operators.
    directives. If <directive module="mod_include"
    >SSILegacyExprParser</directive> is set to <code>on</code>,
    substitution also occures in the arguments to conditional operators.
    You can insert a literal dollar sign into the string using backslash
    quoting:</p>

    <example>
      &lt;!--#if expr="$a = \$test" --&gt;
      &lt;!--#set var="cur" value="\$test" --&gt;
    </example>

    <p>If a variable reference needs to be substituted in the
@@ -526,26 +528,6 @@
    to "<code>X_Y</code>" if <code>REMOTE_HOST</code> is
    "<code>X</code>" and <code>REQUEST_METHOD</code> is
    "<code>Y</code>".</p>

    <p>The below example will print "in foo" if the
    <code>DOCUMENT_URI</code> is <code>/foo/file.html</code>, "in bar"
    if it is <code>/bar/file.html</code> and "in neither" otherwise:</p>

    <example>
      &lt;!--#if expr='"$DOCUMENT_URI" = "/foo/file.html"' --&gt;<br />
      <indent>
        in foo<br />
      </indent>
      &lt;!--#elif expr='"$DOCUMENT_URI" = "/bar/file.html"' --&gt;<br />
      <indent>
        in bar<br />
      </indent>
      &lt;!--#else --&gt;<br />
      <indent>
        in neither<br />
      </indent>
      &lt;!--#endif --&gt;
    </example>
</section>

<section id="flowctrl">
@@ -573,7 +555,55 @@
    <p>The <code>endif</code> element ends the <code>if</code> element
    and is required.</p>

    <p><var>test_condition</var> is one of the following:</p>
    <p><var>test_condition</var> is a boolean expression tha follows the
    <a href="../expr.html">ap_expr</a> syntax. The syntax can be changed
    to be compatible with Apache HTTPD 2.2.x using <directive
    module="mod_include">SSILegacyExprParser</directive>.</p>

    <p>The SSI variables set with the <code>var</code> element are exported
    into the request environment and can be accessed with the
    <code>reqenv</code> function. As a short-cut, the function name
    <code>v</code> is also available inside <module>mod_include</module>.</p>

    <p>The below example will print "from local net" if client IP address
    belongs to the 10.0.0.0/8 subnet.</p>

    <example>
      &lt;!--#if expr='-R "10.0.0.0/8"' --&gt;<br />
      <indent>
        from local net<br />
      </indent>
      &lt;!--#else --&gt;<br />
      <indent>
        from somewhere else<br />
      </indent>
      &lt;!--#endif --&gt;
    </example>

    <p>The below example will print "foo is bar" if the variable
    <code>foo</code> is set to the value "bar".</p>

    <example>
      &lt;!--#if expr='v("foo") = "bar"' --&gt;<br />
      <indent>
        foo is bar<br />
      </indent>
      &lt;!--#endif --&gt;
    </example>

    <note><title>Reference Documentation</title>
    <p>See also: <a href="../expr.html">Expressions in Apache HTTP Server</a>,
    for a complete reference and examples. The <em>restricted</em> functions
    are not available inside <module>mod_include</module></p>
    </note>
</section>

<section id="legacyexpr">
    <title>Legacy expression syntax</title>

    <p>This section describes the syntax of the <code>#if expr</code>
    element if <directive module="mod_include">SSILegacyExprParser</directive>
    is set to <code>on</code>.</p>

    <dl>
      <dt><code><var>string</var></code></dt>
@@ -713,12 +743,6 @@
     be escaped.  This is regardless of their meaning to the regex engine.</p>
    </note>

    <!-- mod_include does not use ap_expr, yet
    <note><title>Reference Documentation</title>
    <p>See also: <a href="../expr.html">Expressions in Apache HTTP Server</a>,
    for a complete reference and examples.</p>
    </note>
    -->
</section>

<directivesynopsis>
@@ -856,14 +880,20 @@ displayed</description>

<directivesynopsis>
<name>SSIAccessEnable</name>
<description>Enable the -A flag during conditional flow control processing.</description>
<description>Enable the -A flag in legacy conditional expressions.</description>
<syntax>SSIAccessEnable on|off</syntax>
<default>SSIAccessEnable off</default>
<contextlist><context>directory</context><context>.htaccess</context></contextlist>

<usage>
    <note><directive>SSIAccessEnable</directive> has no effect unless
    <directive module="mod_include">SSILegacyExprParser</directive> is set to
    <code>on</code>.
    </note>

    <p>The <directive>SSIAccessEnable</directive> directive controls whether
    the -A test is enabled during conditional flow control processing.
    the -A test is enabled during conditional flow control processing when
    using the 2.2.x compatible expression parser.
    <directive>SSIAccessEnable</directive> can take on the following values:</p>

    <dl>
@@ -962,6 +992,24 @@ server.</description>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>SSILegacyExprParser</name>
<description>Enable compatibility mode for conditional expressions.</description>
<syntax>SSILegacyExprParser on|off</syntax>
<default>SSILegacyExprParser off</default>
<contextlist><context>directory</context><context>.htaccess</context></contextlist>
<compatibility>Available in version 2.3.13 and later.</compatibility>

<usage>
    <p>As of version 2.3.13, <module>mod_include</module> has switched to the
    new <a href="../expr.html">ap_expr</a> syntax for conditional expressions
    in <code>#if</code> flow control elements.  This directive allows to
    switch to the <a href="#legacyexpr">old syntax</a> which is compatible
    with Apache HTTPD version 2.2.x and earlier. 
    </p>
</usage>
</directivesynopsis>

<directivesynopsis>
<name>XBitHack</name>
<description>Parse SSI directives in files with the execute bit
Loading