aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@helixcode.com>2000-11-04 04:55:02 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2000-11-04 04:55:02 +0800
commit4e0d5fd52a9825724abe9955f742b6ca53d6a438 (patch)
tree117dcc54a8c5a8439f247e1d3d75d6b24359d11e /camel
parentf2f3ee373bf8c847aa20e37fd1caac1c6b4430ac (diff)
downloadgsoc2013-evolution-4e0d5fd52a9825724abe9955f742b6ca53d6a438.tar.gz
gsoc2013-evolution-4e0d5fd52a9825724abe9955f742b6ca53d6a438.tar.zst
gsoc2013-evolution-4e0d5fd52a9825724abe9955f742b6ca53d6a438.zip
If show_pass, then base64 the password before writing it to the output
2000-11-03 Jeffrey Stedfast <fejj@helixcode.com> * camel-url.c (camel_url_to_string): If show_pass, then base64 the password before writing it to the output string. (camel_url_new): Assume password has been base64 encoded and decode accordingly. svn path=/trunk/; revision=6374
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog7
-rw-r--r--camel/camel-url.c40
2 files changed, 41 insertions, 6 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 026ee4605a..6c83938fe9 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,10 @@
+2000-11-03 Jeffrey Stedfast <fejj@helixcode.com>
+
+ * camel-url.c (camel_url_to_string): If show_pass, then base64 the
+ password before writing it to the output string.
+ (camel_url_new): Assume password has been base64 encoded and
+ decode accordingly.
+
2000-11-03 Dan Winship <danw@helixcode.com>
* camel-provider.h: Add an "url_flags" field to CamelProvider.
diff --git a/camel/camel-url.c b/camel/camel-url.c
index 04c84dc450..f78a4cefc2 100644
--- a/camel/camel-url.c
+++ b/camel/camel-url.c
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include "camel-url.h"
+#include "camel-mime-utils.h"
#include "camel-exception.h"
#include "camel-object.h"
@@ -69,7 +70,7 @@ camel_url_new (const char *url_string, CamelException *ex)
CamelURL *url;
char *semi, *colon, *at, *slash;
char *p;
-
+
/* Find protocol: initial substring until ":" */
colon = strchr (url_string, ':');
if (!colon) {
@@ -78,7 +79,7 @@ camel_url_new (const char *url_string, CamelException *ex)
url_string);
return NULL;
}
-
+
url = g_new0 (CamelURL, 1);
url->protocol = g_strndup (url_string, colon - url_string);
g_strdown (url->protocol);
@@ -115,8 +116,19 @@ camel_url_new (const char *url_string, CamelException *ex)
if (at && (!slash || at < slash)) {
colon = strchr (url_string, ':');
if (colon && colon < at) {
- url->passwd = g_strndup (colon + 1, at - colon - 1);
- camel_url_decode (url->passwd);
+ /* assume password is base64 encoded */
+ int state = 0; int save = 0;
+ char *passwd;
+ int len;
+
+ passwd = g_strndup (colon + 1, at - colon - 1);
+ camel_url_decode (passwd);
+
+ len = strlen (passwd);
+ url->passwd = g_malloc (len);
+ len = base64_decode_step (passwd, len, url->passwd, &state, &save);
+
+ url->passwd[len] = '\0';
} else {
url->passwd = NULL;
colon = at;
@@ -183,16 +195,32 @@ camel_url_to_string (CamelURL *url, gboolean show_passwd)
if (url->user)
user = camel_url_encode (url->user, TRUE, ":;@/");
+
if (url->authmech)
authmech = camel_url_encode (url->authmech, TRUE, ":@/");
- if (show_passwd && url->passwd)
- passwd = camel_url_encode (url->passwd, TRUE, "@/");
+
+ if (show_passwd && url->passwd) {
+ int state = 0, save = 0;
+ int len;
+ char *pass;
+
+ len = strlen (url->passwd);
+ pass = g_malloc ((int)(len * 4 / 3) + 4);
+ len = base64_encode_close (url->passwd, len, FALSE, pass, &state, &save);
+ pass[len] = '\0';
+
+ passwd = camel_url_encode (pass, TRUE, "/");
+ g_free (pass);
+ }
+
if (url->host)
host = camel_url_encode (url->host, TRUE, ":/");
+
if (url->port)
g_snprintf (port, sizeof (port), "%d", url->port);
else
*port = '\0';
+
if (url->path)
path = camel_url_encode (url->path, FALSE, NULL);