You are viewing a plain text version of this content. The canonical link for it is here.
Posted to docs@httpd.apache.org by bu...@apache.org on 2021/01/05 02:54:53 UTC

[Bug 65057] New: ambiguities in

https://bz.apache.org/bugzilla/show_bug.cgi?id=65057

            Bug ID: 65057
           Summary: ambiguities in <DirectoryMatch>
           Product: Apache httpd-2
           Version: 2.5-HEAD
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Documentation
          Assignee: docs@httpd.apache.org
          Reporter: calestyo@scientia.net
  Target Milestone: ---

In at least mod/core.html’s documentation of <DirectoryMatch> (probably
<FileMatch> <LocationMatch>, too):

1) "<DirectoryMatch> and </DirectoryMatch> are used to enclose a group of
directives which will apply only to the named directory (and the files within),
the same as <Directory>."

Well since 2.3.9. exactly this is NO LONGER the case, the sentence should be
improved to e.g.
"<DirectoryMatch> and </DirectoryMatch> are used to enclose a group of
directives which will apply to matching directories (and the (non-directory)
files within) only."

Perhaps adding one like:
"Unlike with (the non regular-experession version of) <Directory> they don't
apply to any subdirectories, unless these are matched by the regular
expression, too."


2) Also it's not really clear whether and how any implicit anchoring is done to
^ and ?,... i.e. to which of the following regexps is <DirectoryMatch
"/var/www"> effectively identical to:
/var/www => would also match /usr/var/www or /usr/var/wwwbar 
^/var/www => would also match /usr/var/wwwbar or /usr/var/www/bar 
^/var/www/ => would also match any subdirs thereof

or is it what's expected:
^/var/www$
^/var/www/$
i.e. only the directory itself.


Depending on which it is, the documentation's example using
"^/www/(.+/)?[0-9]{3}/" might be wrong too, as this has no explicit $ anchor
and would thus also match /www/something/999/andEvenMore



3) At least to me, the following is not clear:
"This directive applies to requests for directories that may or may not end in
a trailing slash, so expressions that are anchored to the end of line ($) must
be written with care."

I mean for <Location> I'd understand cause there "/foo" is something different
than "/foo/", but for file system directories it's the same if it's a
directory.

So from my understanding:
^/var/www$
^/var/www/$
should be the very same if I want to match only /var/www and no subdirs, while
e.g.
^/var/www => would match anything where the 2nd lvl starts with www
^/var/www/ => would match /var/www and any of it's subdirs


Cheers,
Chris.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


[Bug 65057] ambiguities in

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65057

--- Comment #2 from Christoph Anton Mitterer <ca...@scientia.net> ---
Last but not least... the solution from Bug 32635 is still/again wrong (either
the regexp, or the description).

"^/www/.*/[0-9]{3}" is not anchored to $, so not only will it also match e.g.
/www/333aaa but also /www/333/and/even/more .


Cheers,
Chris.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


[Bug 65057] ambiguities in

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=65057

--- Comment #1 from Christoph Anton Mitterer <ca...@scientia.net> ---
I've tested (3) with mod_dir disabled and it seems Apache does the following:


1) there is no automatic anchoring to ^ or $ if the regexp doesn't contain them
so e.g. "^/var/www" would also match /var/www/foo/ and /var/wwwbar/
(admittedly I only tested for $,... and was too lazy for ^ ... some developer
please confirm)


2) The path, is taken from the URI, but multiple consecutive / are merged i.e.
/var///www/ becomes /var/www/ .

(which is btw. also missing from the documentation)


3) From the URL given, which is then take as the path relative to the
DocumentDir, there is no implicit addition or removal of a trailing /
(if mod_dir is not enabled).

That means if my regexp is like these (and DocumentRoot = /):
-"^/var/www/$"
 it matches http://example.org/var/www/ but not http://example.org/var/www
-"^/var/www$"
 it matches http://example.org/var/www but not http://example.org/var/www/

Neither of those two would match subdirs or appended stuff like /var/wwwbar

One should tell people to either use mod_dir and make sure their regexps have
the trailing / ... or if they don't want to use something like:
-"^/var/www/?$"
which would match again both URLs, with and without trailing /



Guess these three points would be valuable to the documentation.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org