subversion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bre...@apache.org
Subject svn commit: r1515201 - /subversion/trunk/subversion/libsvn_ra_serf/util.c
Date Sun, 18 Aug 2013 19:42:23 GMT
Author: breser
Date: Sun Aug 18 19:42:23 2013
New Revision: 1515201

URL: http://svn.apache.org/r1515201
Log:
ra_serf: Don't assume length of translated messages.

* subversion/libsvn_ra_serf/util.c
  (append_reason): New function.
  (ssl_server_cert): Use append_reason() instead of blindly adding separators
    and then chopping them off if they aren't needed.

Modified:
    subversion/trunk/subversion/libsvn_ra_serf/util.c

Modified: subversion/trunk/subversion/libsvn_ra_serf/util.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_serf/util.c?rev=1515201&r1=1515200&r2=1515201&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_serf/util.c (original)
+++ subversion/trunk/subversion/libsvn_ra_serf/util.c Sun Aug 18 19:42:23 2013
@@ -243,6 +243,16 @@ convert_organisation_to_str(apr_hash_t *
   return buf->data;
 }
 
+static void append_reason(svn_stringbuf_t *errmsg, const char *reason, int *reasons)
+{
+  if (*reasons < 1)
+    svn_stringbuf_appendcstr(errmsg, _(": "));
+  else
+    svn_stringbuf_appendcstr(errmsg, _(", "));
+  svn_stringbuf_appendcstr(errmsg, reason);
+  (*reasons)++;
+}
+
 /* This function is called on receiving a ssl certificate of a server when
    opening a https connection. It allows Subversion to override the initial
    validation done by serf.
@@ -347,26 +357,26 @@ ssl_server_cert(void *baton, int failure
   if (!server_creds)
     {
       svn_stringbuf_t *errmsg;
+      int reasons = 0;
 
       errmsg = svn_stringbuf_create(
-                 _("Server SSL certificate verification failed: "),
+                 _("Server SSL certificate verification failed"),
                  scratch_pool);
 
+
       if (svn_failures & SVN_AUTH_SSL_NOTYETVALID)
-        svn_stringbuf_appendcstr(errmsg, _("certificate is not yet valid, "));
+        append_reason(errmsg, _("certificate is not yet valid"), &reasons);
 
       if (svn_failures & SVN_AUTH_SSL_EXPIRED)
-        svn_stringbuf_appendcstr(errmsg, _("certificate has expired, "));
+        append_reason(errmsg, _("certificate has expired"), &reasons);
 
       if (svn_failures & SVN_AUTH_SSL_CNMISMATCH)
-        svn_stringbuf_appendcstr(errmsg,
-          _("certificate issued for a different hostname, "));
+        append_reason(errmsg,
+                      _("certificate issued for a different hostname"),
+                      &reasons);
 
       if (svn_failures & SVN_AUTH_SSL_UNKNOWNCA)
-        svn_stringbuf_appendcstr(errmsg, _("issuer is not trusted, "));
-
-      /* Chop last two characters. It could be ', ' or ': '. */
-      svn_stringbuf_chop(errmsg, 2);
+        append_reason(errmsg, _("issuer is not trusted"), &reasons);
 
       return svn_error_create(SVN_ERR_RA_SERF_SSL_CERT_UNTRUSTED, NULL,
                               errmsg->data);



Mime
View raw message