subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmpil...@apache.org
Subject svn commit: r1215260 - /subversion/trunk/subversion/mod_dav_svn/reports/log.c
Date Fri, 16 Dec 2011 20:14:52 GMT
Author: cmpilato
Date: Fri Dec 16 20:14:52 2011
New Revision: 1215260

URL: http://svn.apache.org/viewvc?rev=1215260&view=rev
Log:
Finish the server-side bit of issue #4082.

Check for a flag in the client's XML REPORT request for log revisions
which means "encode any binary property values before trying to send
them across the wire", and honor that request.  We'll use base64
encoding, just as we do in other portions of mod_dav_svn.  Clients
which don't request this encoding of binary properties will have to
endure the previous behavior for compatibility's sake.

* subversion/mod_dav_svn/reports/log.c
  (struct log_receiver_baton): Add 'encode_binary_props' member.
  (log_receiver): If the client supports binary property encoding, and
    we've a non-XML-safe value to transmit, then base64-encode that
    sucker when embedding it into our XML response.
  (dav_svn__log_report): Initialize the baton's 'encode_binary_props'
    member, and check for the XML tag which means "Please encode
    binary property values."

Modified:
    subversion/trunk/subversion/mod_dav_svn/reports/log.c

Modified: subversion/trunk/subversion/mod_dav_svn/reports/log.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/mod_dav_svn/reports/log.c?rev=1215260&r1=1215259&r2=1215260&view=diff
==============================================================================
--- subversion/trunk/subversion/mod_dav_svn/reports/log.c (original)
+++ subversion/trunk/subversion/mod_dav_svn/reports/log.c Fri Dec 16 20:14:52 2011
@@ -30,6 +30,7 @@
 #include "svn_repos.h"
 #include "svn_string.h"
 #include "svn_types.h"
+#include "svn_base64.h"
 #include "svn_xml.h"
 #include "svn_path.h"
 #include "svn_dav.h"
@@ -61,6 +62,9 @@ struct log_receiver_baton
 
   /* whether the client requested any custom revprops */
   svn_boolean_t requested_custom_revprops;
+
+  /* whether the client can handle encoded binary property values */
+  svn_boolean_t encode_binary_props;
 };
 
 
@@ -119,35 +123,50 @@ log_receiver(void *baton,
            hi = apr_hash_next(hi))
         {
           char *name;
-          svn_string_t *value;
+          void *val;
+          const svn_string_t *value;
+          const char *encoding_str = "";
 
           svn_pool_clear(iterpool);
-          apr_hash_this(hi, (void *)&name, NULL, (void *)&value);
+          apr_hash_this(hi, (void *)&name, NULL, &val);
+          value = val;
+
+          /* If the client is okay with us encoding binary (or really,
+             any non-XML-safe) property values, do so as necessary. */
+          if (lrb->encode_binary_props)
+            {
+              if (! svn_xml_is_xml_safe(value->data, value->len))
+                {
+                  value = svn_base64_encode_string2(value, TRUE, iterpool);
+                  encoding_str = " encoding=\"base64\"";
+                }
+            }
+
           if (strcmp(name, SVN_PROP_REVISION_AUTHOR) == 0)
             SVN_ERR(dav_svn__brigade_printf
                     (lrb->bb, lrb->output,
-                     "<D:creator-displayname>%s</D:creator-displayname>"
-                     DEBUG_CR,
+                     "<D:creator-displayname%s>%s</D:creator-displayname>"
+                     DEBUG_CR, encoding_str,
                      apr_xml_quote_string(iterpool, value->data, 0)));
           else if (strcmp(name, SVN_PROP_REVISION_DATE) == 0)
             /* ### this should be DAV:creation-date, but we need to format
                ### that date a bit differently */
             SVN_ERR(dav_svn__brigade_printf
                     (lrb->bb, lrb->output,
-                     "<S:date>%s</S:date>" DEBUG_CR,
+                     "<S:date%s>%s</S:date>" DEBUG_CR, encoding_str,
                      apr_xml_quote_string(iterpool, value->data, 0)));
           else if (strcmp(name, SVN_PROP_REVISION_LOG) == 0)
             SVN_ERR(dav_svn__brigade_printf
                     (lrb->bb, lrb->output,
-                     "<D:comment>%s</D:comment>" DEBUG_CR,
+                     "<D:comment%s>%s</D:comment>" DEBUG_CR, encoding_str,
                      apr_xml_quote_string(pool,
                                           svn_xml_fuzzy_escape(value->data,
                                                                iterpool), 0)));
           else
             SVN_ERR(dav_svn__brigade_printf
                     (lrb->bb, lrb->output,
-                     "<S:revprop name=\"%s\">%s</S:revprop>" DEBUG_CR,
-                     apr_xml_quote_string(iterpool, name, 0),
+                     "<S:revprop name=\"%s\"%s>%s</S:revprop>" DEBUG_CR,
+                     apr_xml_quote_string(iterpool, name, 0), encoding_str,
                      apr_xml_quote_string(iterpool, value->data, 0)));
         }
     }
@@ -305,6 +324,7 @@ dav_svn__log_report(const dav_resource *
   seen_revprop_element = FALSE;
 
   lrb.requested_custom_revprops = FALSE;
+  lrb.encode_binary_props = FALSE;
   for (child = doc->root->first_child; child != NULL; child = child->next)
     {
       /* if this element isn't one of ours, then skip it */
@@ -333,6 +353,8 @@ dav_svn__log_report(const dav_resource *
         strict_node_history = TRUE; /* presence indicates positivity */
       else if (strcmp(child->name, "include-merged-revisions") == 0)
         include_merged_revisions = TRUE; /* presence indicates positivity */
+      else if (strcmp(child->name, "encode-binary-props") == 0)
+        lrb.encode_binary_props = TRUE; /* presence indicates positivity */
       else if (strcmp(child->name, "all-revprops") == 0)
         {
           revprops = NULL; /* presence indicates fetch all revprops */



Mime
View raw message