Mailing List Archive

Re: svn commit: r1879888 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/dav/main/mod_dav.h modules/dav/main/util.c
Seems these helper functions would be a better fit within apr_xml, rather
than httpd.


On Wed, Jul 15, 2020 at 8:16 AM <minfrin@apache.org> wrote:

> Author: minfrin
> Date: Wed Jul 15 13:16:19 2020
> New Revision: 1879888
>
> URL: http://svn.apache.org/viewvc?rev=1879888&view=rev
> Log:
> mod_dav: Add utility functions dav_validate_root_ns(),
> dav_find_child_ns(), dav_find_next_ns(), dav_find_attr_ns() and
> dav_find_attr() so that other modules get to play too.
>
> Modified:
> httpd/httpd/trunk/CHANGES
> httpd/httpd/trunk/include/ap_mmn.h
> httpd/httpd/trunk/modules/dav/main/mod_dav.h
> httpd/httpd/trunk/modules/dav/main/util.c
>
> Modified: httpd/httpd/trunk/CHANGES
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1879888&r1=1879887&r2=1879888&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/CHANGES [utf-8] (original)
> +++ httpd/httpd/trunk/CHANGES [utf-8] Wed Jul 15 13:16:19 2020
> @@ -1,6 +1,10 @@
> -*- coding:
> utf-8 -*-
> Changes with Apache 2.5.1
>
> + *) mod_dav: Add utility functions dav_validate_root_ns(),
> + dav_find_child_ns(), dav_find_next_ns(), dav_find_attr_ns() and
> + dav_find_attr() so that other modules get to play too.
> + [Graham Leggett]
>
> *) mod_http2:
> Fixes <https://github.com/icing/mod_h2/issues/200>:
>
> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1879888&r1=1879887&r2=1879888&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Wed Jul 15 13:16:19 2020
> @@ -654,6 +654,9 @@
> * 20200703.0 (2.5.1-dev) Remove ap_md5digest(), ap_md5contextTo64(),
> * ContentDigest directive.
> * 20200705.0 (2.5.1-dev) Update method_precondition hook.
> + * 20200705.1 (2.5.1-dev) Add dav_validate_root_ns(),
> dav_find_child_ns(),
> + * dav_find_next_ns(), dav_find_attr_ns() and
> + * dav_find_attr().
> */
>
> #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
> @@ -661,7 +664,7 @@
> #ifndef MODULE_MAGIC_NUMBER_MAJOR
> #define MODULE_MAGIC_NUMBER_MAJOR 20200705
> #endif
> -#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
> +#define MODULE_MAGIC_NUMBER_MINOR 1 /* 0...n */
>
> /**
> * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
>
> Modified: httpd/httpd/trunk/modules/dav/main/mod_dav.h
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/mod_dav.h?rev=1879888&r1=1879887&r2=1879888&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/mod_dav.h (original)
> +++ httpd/httpd/trunk/modules/dav/main/mod_dav.h Wed Jul 15 13:16:19 2020
> @@ -583,8 +583,22 @@ DAV_DECLARE(int) dav_get_depth(request_r
>
> DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc,
> const char *tagname);
> +DAV_DECLARE(int) dav_validate_root_ns(const apr_xml_doc *doc,
> + int ns, const char *tagname);
> DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem,
> const char *tagname);
> +DAV_DECLARE(apr_xml_elem *) dav_find_child_ns(const apr_xml_elem *elem,
> + int ns, const char
> *tagname);
> +DAV_DECLARE(apr_xml_elem *) dav_find_next_ns(const apr_xml_elem *elem,
> + int ns, const char *tagname);
> +
> +/* find and return the attribute with a name in the given namespace */
> +DAV_DECLARE(apr_xml_attr *) dav_find_attr_ns(const apr_xml_elem *elem,
> + int ns, const char
> *attrname);
> +
> +/* find and return the attribute with a given DAV: tagname */
> +DAV_DECLARE(apr_xml_attr *) dav_find_attr(const apr_xml_elem *elem,
> + const char *attrname);
>
> /* gather up all the CDATA into a single string */
> DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem,
> apr_pool_t *pool,
>
> Modified: httpd/httpd/trunk/modules/dav/main/util.c
> URL:
> http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/dav/main/util.c?rev=1879888&r1=1879887&r2=1879888&view=diff
>
> ==============================================================================
> --- httpd/httpd/trunk/modules/dav/main/util.c (original)
> +++ httpd/httpd/trunk/modules/dav/main/util.c Wed Jul 15 13:16:19 2020
> @@ -316,26 +316,71 @@ DAV_DECLARE(dav_lookup_result) dav_looku
> */
>
> /* validate that the root element uses a given DAV: tagname (TRUE==valid)
> */
> -DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc,
> - const char *tagname)
> +DAV_DECLARE(int) dav_validate_root_ns(const apr_xml_doc *doc,
> + int ns, const char *tagname)
> {
> return doc->root &&
> - doc->root->ns == APR_XML_NS_DAV_ID &&
> + doc->root->ns == ns &&
> strcmp(doc->root->name, tagname) == 0;
> }
>
> -/* find and return the (unique) child with a given DAV: tagname */
> -DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem,
> - const char *tagname)
> +/* validate that the root element uses a given DAV: tagname (TRUE==valid)
> */
> +DAV_DECLARE(int) dav_validate_root(const apr_xml_doc *doc,
> + const char *tagname)
> +{
> + return dav_validate_root_ns(doc, APR_XML_NS_DAV_ID, tagname);
> +}
> +
> +/* find and return the next child with a tagname in the given namespace */
> +DAV_DECLARE(apr_xml_elem *) dav_find_next_ns(const apr_xml_elem *elem,
> + int ns, const char *tagname)
> +{
> + apr_xml_elem *child = elem->next;
> +
> + for (; child; child = child->next)
> + if (child->ns == ns && !strcmp(child->name, tagname))
> + return child;
> + return NULL;
> +}
> +
> +/* find and return the (unique) child with a tagname in the given
> namespace */
> +DAV_DECLARE(apr_xml_elem *) dav_find_child_ns(const apr_xml_elem *elem,
> + int ns, const char *tagname)
> {
> apr_xml_elem *child = elem->first_child;
>
> for (; child; child = child->next)
> - if (child->ns == APR_XML_NS_DAV_ID && !strcmp(child->name,
> tagname))
> + if (child->ns == ns && !strcmp(child->name, tagname))
> return child;
> return NULL;
> }
>
> +/* find and return the (unique) child with a given DAV: tagname */
> +DAV_DECLARE(apr_xml_elem *) dav_find_child(const apr_xml_elem *elem,
> + const char *tagname)
> +{
> + return dav_find_child_ns(elem, APR_XML_NS_DAV_ID, tagname);
> +}
> +
> +/* find and return the attribute with a name in the given namespace */
> +DAV_DECLARE(apr_xml_attr *) dav_find_attr_ns(const apr_xml_elem *elem,
> + int ns, const char *attrname)
> +{
> + apr_xml_attr *attr = elem->attr;
> +
> + for (; attr; attr = attr->next)
> + if (attr->ns == ns && !strcmp(attr->name, attrname))
> + return attr;
> + return NULL;
> +}
> +
> +/* find and return the attribute with a given DAV: tagname */
> +DAV_DECLARE(apr_xml_attr *) dav_find_attr(const apr_xml_elem *elem,
> + const char *attrname)
> +{
> + return dav_find_attr_ns(elem, APR_XML_NS_DAV_ID, attrname);
> +}
> +
> /* gather up all the CDATA into a single string */
> DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem,
> apr_pool_t *pool,
> int strip_white)
>
>
>
Re: svn commit: r1879888 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/dav/main/mod_dav.h modules/dav/main/util.c [ In reply to ]
On 15 Jul 2020, at 15:33, Greg Stein <gstein@gmail.com> wrote:

> Seems these helper functions would be a better fit within apr_xml, rather than httpd.

In the long term, yes.

In the “it must be practical to use this with v2.4” term, I’d rather continue with the established pattern, and then move the lot of these functions as a future mod_dav cleanup. I don't want to boil the ocean at this point, there has already been a lot of change to make things work.

Regards,
Graham