You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mi...@apache.org on 2014/01/03 23:26:55 UTC
svn commit: r1555266 - in /httpd/httpd/trunk: docs/manual/mod/core.xml
docs/manual/mod/mod_proxy.xml include/ap_regex.h modules/proxy/mod_proxy.c
server/core.c server/util_pcre.c
Author: minfrin
Date: Fri Jan 3 22:26:55 2014
New Revision: 1555266
URL: http://svn.apache.org/r1555266
Log:
Add a "MATCH_" prefix to variables set within
LocationMatch/DirectoryMatch/FilesMatch.
Modified:
httpd/httpd/trunk/docs/manual/mod/core.xml
httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml
httpd/httpd/trunk/include/ap_regex.h
httpd/httpd/trunk/modules/proxy/mod_proxy.c
httpd/httpd/trunk/server/core.c
httpd/httpd/trunk/server/util_pcre.c
Modified: httpd/httpd/trunk/docs/manual/mod/core.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/core.xml?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/core.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/core.xml Fri Jan 3 22:26:55 2014
@@ -887,15 +887,15 @@ the contents of file-system directories
</note>
<p>From 2.5.0 onwards, named groups and backreferences are captured and
- written to the environment with the corresponding name in upper case.
- This allows elements of paths to be referenced from within
- <a href="expr.html">expressions</a> and modules like
+ written to the environment with the corresponding name prefixed with
+ "MATCH_" and in upper case. This allows elements of paths to be referenced
+ from within <a href="expr.html">expressions</a> and modules like
<module>mod_rewrite</module>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<DirectoryMatch ^/var/www/combined/(?<SITENAME>[^/]+)>
- require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+<DirectoryMatch ^/var/www/combined/(?<sitename>[^/]+)>
+ require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</DirectoryMatch>
</highlight>
</usage>
@@ -1750,15 +1750,15 @@ filenames</description>
<p>would match most common Internet graphics formats.</p>
<p>From 2.5.0 onwards, named groups and backreferences are captured and
- written to the environment with the corresponding name in upper case.
- This allows elements of files to be referenced from within
- <a href="expr.html">expressions</a> and modules like
+ written to the environment with the corresponding name prefixed with
+ "MATCH_" and in upper case. This allows elements of files to be referenced
+ from within <a href="expr.html">expressions</a> and modules like
<module>mod_rewrite</module>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<FileMatch ^(?<SITENAME>[^/]+)>
- require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+<FileMatch ^(?<sitename>[^/]+)>
+ require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</FileMatch>
</highlight>
</usage>
@@ -2716,15 +2716,15 @@ matching URLs</description>
or <code>/special/data</code>.</p>
<p>From 2.5.0 onwards, named groups and backreferences are captured and
- written to the environment with the corresponding name in upper case.
- This allows elements of URLs to be referenced from within
- <a href="expr.html">expressions</a> and modules like
+ written to the environment with the corresponding name prefixed with
+ "MATCH_" and in upper case. This allows elements of URLs to be referenced
+ from within <a href="expr.html">expressions</a> and modules like
<module>mod_rewrite</module>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<LocationMatch ^/combined/(?<SITENAME>[^/]+)>
- require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+<LocationMatch ^/combined/(?<sitename>[^/]+)>
+ require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</LocationMatch>
</highlight>
</usage>
Modified: httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml Fri Jan 3 22:26:55 2014
@@ -530,15 +530,15 @@ proxied resources</description>
using <glossary ref="regex">regular expressions</glossary>.</p>
<p>From 2.5.0 onwards, named groups and backreferences are captured and
- written to the environment with the corresponding name in upper case.
- This allows elements of URLs to be referenced from within
- <a href="expr.html">expressions</a> and modules like
+ written to the environment with the corresponding name prefixed with
+ "MATCH_" and in upper case. This allows elements of URLs to be referenced
+ from within <a href="expr.html">expressions</a> and modules like
<module>mod_rewrite</module>. In order to prevent confusion, numbered
(unnamed) backreferences are ignored. Use named groups instead.</p>
<highlight language="config">
-<ProxyMatch ^http://(?<SITENAME>[^/]+)>
- require ldap-group cn=%{env:SITENAME},ou=combined,o=Example
+<ProxyMatch ^http://(?<sitename>[^/]+)>
+ require ldap-group cn=%{env:MATCH_SITENAME},ou=combined,o=Example
</ProxyMatch>
</highlight>
</usage>
Modified: httpd/httpd/trunk/include/ap_regex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_regex.h?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_regex.h (original)
+++ httpd/httpd/trunk/include/ap_regex.h Fri Jan 3 22:26:55 2014
@@ -77,6 +77,8 @@ extern "C" {
#define AP_REG_NOMEM 0x20 /* nomem in our code */
#define AP_REG_DOTALL 0x40 /* perl's /s flag */
+#define AP_REG_MATCH "MATCH_" /** suggested prefix for ap_regname */
+
/* Error values: */
enum {
AP_REG_ASSERT = 1, /** internal error ? */
@@ -156,7 +158,8 @@ AP_DECLARE(apr_size_t) ap_regerror(int e
* @param upper If non zero, uppercase the names
*/
AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
- apr_array_header_t *names, int upper);
+ apr_array_header_t *names, const char *prefix,
+ int upper);
/** Destroy a pre-compiled regex.
* @param preg The pre-compiled regex to free.
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Fri Jan 3 22:26:55 2014
@@ -2275,7 +2275,7 @@ static const char *proxysection(cmd_parm
if (r) {
conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
- ap_regname(r, conf->refs, 1);
+ ap_regname(r, conf->refs, AP_REG_MATCH, 1);
}
ap_add_per_proxy_conf(cmd->server, new_dir_conf);
Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Fri Jan 3 22:26:55 2014
@@ -2223,7 +2223,7 @@ static const char *dirsection(cmd_parms
if (r) {
conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
- ap_regname(r, conf->refs, 1);
+ ap_regname(r, conf->refs, AP_REG_MATCH, 1);
}
/* Make this explicit - the "/" root has 0 elements, that is, we
@@ -2304,7 +2304,7 @@ static const char *urlsection(cmd_parms
if (r) {
conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
- ap_regname(r, conf->refs, 1);
+ ap_regname(r, conf->refs, AP_REG_MATCH, 1);
}
ap_add_per_url_conf(cmd->server, new_url_conf);
@@ -2391,7 +2391,7 @@ static const char *filesection(cmd_parms
if (r) {
conf->refs = apr_array_make(cmd->pool, 8, sizeof(char *));
- ap_regname(r, conf->refs, 1);
+ ap_regname(r, conf->refs, AP_REG_MATCH, 1);
}
ap_add_file_conf(cmd->pool, (core_dir_config *)mconfig, new_file_conf);
Modified: httpd/httpd/trunk/server/util_pcre.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_pcre.c?rev=1555266&r1=1555265&r2=1555266&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_pcre.c (original)
+++ httpd/httpd/trunk/server/util_pcre.c Fri Jan 3 22:26:55 2014
@@ -258,7 +258,8 @@ AP_DECLARE(int) ap_regexec_len(const ap_
}
AP_DECLARE(int) ap_regname(const ap_regex_t *preg,
- apr_array_header_t *names, int upper)
+ apr_array_header_t *names, const char *prefix,
+ int upper)
{
int namecount;
int nameentrysize;
@@ -278,10 +279,14 @@ AP_DECLARE(int) ap_regname(const ap_rege
while (names->nelts <= capture) {
apr_array_push(names);
}
- if (upper) {
- char *name = ((char **)names->elts)[capture] =
- apr_pstrdup(names->pool, offset + 2);
- ap_str_toupper(name);
+ if (upper || prefix) {
+ char *name = ((char **) names->elts)[capture] =
+ prefix ? apr_pstrcat(names->pool, prefix, offset + 2,
+ NULL) :
+ apr_pstrdup(names->pool, offset + 2);
+ if (upper) {
+ ap_str_toupper(name);
+ }
}
else {
((const char **)names->elts)[capture] = offset + 2;