Mailing List Archive

Re: svn commit: r1894456 - in /httpd/httpd/trunk: changes-entries/DirectorySlashNotFound.txt docs/manual/mod/mod_dir.xml modules/mappers/mod_dir.c
welcome to feedback on these, especially the names

On Thu, Oct 21, 2021 at 2:54 PM <covener@apache.org> wrote:
>
> Author: covener
> Date: Thu Oct 21 18:54:46 2021
> New Revision: 1894456
>
> URL: http://svn.apache.org/viewvc?rev=1894456&view=rev
> Log:
> add DirectorySlashNotFound to silence scanners
>
> Almost as awkwardly named as IndexForbiddenReturn404
>
>
> Added:
> httpd/httpd/trunk/changes-entries/DirectorySlashNotFound.txt
> Modified:
> httpd/httpd/trunk/docs/manual/mod/mod_dir.xml
> httpd/httpd/trunk/modules/mappers/mod_dir.c
>
> Added: httpd/httpd/trunk/changes-entries/DirectorySlashNotFound.txt
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/DirectorySlashNotFound.txt?rev=1894456&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/changes-entries/DirectorySlashNotFound.txt (added)
> +++ httpd/httpd/trunk/changes-entries/DirectorySlashNotFound.txt Thu Oct 21 18:54:46 2021
> @@ -0,0 +1,2 @@
> + *) mod_dir: Add "DirectorySlashNotFound" to return 404 instead of a
> + DirectorySlash redirect. [Eric Covener]
>
> Modified: httpd/httpd/trunk/docs/manual/mod/mod_dir.xml
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_dir.xml?rev=1894456&r1=1894455&r2=1894456&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/docs/manual/mod/mod_dir.xml (original)
> +++ httpd/httpd/trunk/docs/manual/mod/mod_dir.xml Thu Oct 21 18:54:46 2021
> @@ -230,6 +230,22 @@ a directory</description>
> </usage>
> </directivesynopsis>
> <directivesynopsis>
> +<name>DirectorySlashNotFound</name>
> +<description>Toggle sending a HTTP 404 error in place of a trailing slash</description>
> +<syntax>DirectorySlashNotFound On|Off</syntax>
> +<default>DirectorySlashNotFound Off</default>
> +<contextlist><context>server config</context><context>virtual host</context>
> +<context>directory</context><context>.htaccess</context></contextlist>
> +<override>Indexes</override>
> +<compatibility>Added in 2.5.1</compatibility>
> +
> +<usage>
> + <p>The <directive>DirectorySlashNotFound</directive> directive determines whether
> + <module>mod_dir</module> should return an HTTP 404 status code where it would
> + otherwise have redirected the request to include a trailing slash. </p>
> +</usage>
> +</directivesynopsis>
> +<directivesynopsis>
> <name>FallbackResource</name>
> <description>Define a default URL for requests that don't map to a file</description>
> <syntax>FallbackResource disabled | <var>local-url</var></syntax>
>
> Modified: httpd/httpd/trunk/modules/mappers/mod_dir.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_dir.c?rev=1894456&r1=1894455&r2=1894456&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/mappers/mod_dir.c (original)
> +++ httpd/httpd/trunk/modules/mappers/mod_dir.c Thu Oct 21 18:54:46 2021
> @@ -48,6 +48,7 @@ typedef struct dir_config_struct {
> moddir_cfg checkhandler;
> int redirect_index;
> const char *dflt;
> + moddir_cfg do_slash_notfound;
> } dir_config_rec;
>
> #define DIR_CMD_PERMS OR_INDEXES
> @@ -88,6 +89,13 @@ static const char *configure_slash(cmd_p
> d->do_slash = arg ? MODDIR_ON : MODDIR_OFF;
> return NULL;
> }
> +static const char *configure_slash_notfound(cmd_parms *cmd, void *d_, int arg)
> +{
> + dir_config_rec *d = d_;
> +
> + d->do_slash_notfound = arg ? MODDIR_ON : MODDIR_OFF;
> + return NULL;
> +}
> static const char *configure_checkhandler(cmd_parms *cmd, void *d_, int arg)
> {
> dir_config_rec *d = d_;
> @@ -132,6 +140,8 @@ static const command_rec dir_cmds[] =
> "a list of file names"),
> AP_INIT_FLAG("DirectorySlash", configure_slash, NULL, DIR_CMD_PERMS,
> "On or Off"),
> + AP_INIT_FLAG("DirectorySlashNotFound", configure_slash_notfound, NULL, DIR_CMD_PERMS,
> + "On or Off"),
> AP_INIT_FLAG("DirectoryCheckHandler", configure_checkhandler, NULL, DIR_CMD_PERMS,
> "On or Off"),
> AP_INIT_TAKE1("DirectoryIndexRedirect", configure_redirect,
> @@ -146,6 +156,7 @@ static void *create_dir_config(apr_pool_
>
> new->index_names = NULL;
> new->do_slash = MODDIR_UNSET;
> + new->do_slash_notfound = MODDIR_UNSET;
> new->checkhandler = MODDIR_UNSET;
> new->redirect_index = REDIRECT_UNSET;
> return (void *) new;
> @@ -160,6 +171,8 @@ static void *merge_dir_configs(apr_pool_
> new->index_names = add->index_names ? add->index_names : base->index_names;
> new->do_slash =
> (add->do_slash == MODDIR_UNSET) ? base->do_slash : add->do_slash;
> + new->do_slash_notfound =
> + (add->do_slash_notfound == MODDIR_UNSET) ? base->do_slash_notfound : add->do_slash_notfound;
> new->checkhandler =
> (add->checkhandler == MODDIR_UNSET) ? base->checkhandler : add->checkhandler;
> new->redirect_index=
> @@ -251,6 +264,10 @@ static int fixup_dir(request_rec *r)
> return DECLINED;
> }
>
> + if (d->do_slash_notfound == MODDIR_ON) {
> + return HTTP_NOT_FOUND;
> + }
> +
> /* Only redirect non-get requests if we have no note to warn
> * that this browser cannot handle redirs on non-GET requests
> * (such as Microsoft's WebFolders).
>
>


--
Eric Covener
covener@gmail.com
Re: svn commit: r1894456 - in /httpd/httpd/trunk: changes-entries/DirectorySlashNotFound.txt docs/manual/mod/mod_dir.xml modules/mappers/mod_dir.c [ In reply to ]
On Thu, Oct 21, 2021 at 8:55 PM Eric Covener <covener@gmail.com> wrote:
>
> welcome to feedback on these, especially the names

DirectorySlash On/Off/NotFound (reusing the existing directive) maybe?
Re: svn commit: r1894456 - in /httpd/httpd/trunk: changes-entries/DirectorySlashNotFound.txt docs/manual/mod/mod_dir.xml modules/mappers/mod_dir.c [ In reply to ]
On Thu, Oct 21, 2021 at 7:50 PM Yann Ylavic <ylavic.dev@gmail.com> wrote:
>
> On Thu, Oct 21, 2021 at 8:55 PM Eric Covener <covener@gmail.com> wrote:
> >
> > welcome to feedback on these, especially the names
>
> DirectorySlash On/Off/NotFound (reusing the existing directive) maybe?

That does "sound" better. Thanks!