SpamReport: use new password API
[claws.git] / src / plugins / spam_report / spam_report.c
index e99660748471b088cfd70aaedcf64d51e5239d90..ce2fadc9674095ff5a98db0fa7329bbe833e4778 100644 (file)
@@ -32,6 +32,7 @@
 #include "common/claws.h"
 #include "common/version.h"
 #include "main.h"
+#include "password.h"
 #include "plugin.h"
 #include "prefs_common.h"
 #include "utils.h"
@@ -43,7 +44,6 @@
 #include "plugin.h"
 #include "menu.h"
 #include "defs.h"
-#include "base64.h"
 #include "procheader.h"
 
 #ifdef USE_PTHREAD
@@ -213,8 +213,7 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
        debug_print("reporting via %s\n", intf->name);
        tmp = spamreport_strreplace(intf->body, "%claws_mail_body%", contents);
        len_contents = strlen(contents);
-       b64 = g_malloc0(B64LEN(len_contents) + 1);
-       base64_encode(b64, contents, len_contents);
+       b64 = g_base64_encode(contents, len_contents);
        reqbody = spamreport_strreplace(tmp, "%claws_mail_body_b64%", b64);
        geturl = spamreport_strreplace(intf->url, "%claws_mail_msgid%", msginfo->msgid);
        g_free(b64);
@@ -223,7 +222,12 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
        switch(intf->type) {
        case INTF_HTTP_AUTH:
                if (spamreport_prefs.user[id] && *(spamreport_prefs.user[id])) {
-                       auth = g_strdup_printf("%s:%s", spamreport_prefs.user[id], spamreport_prefs.pass[id]);
+                       gchar *pass = password_decrypt(spamreport_prefs.pass[id], NULL);
+                       auth = g_strdup_printf("%s:%s", spamreport_prefs.user[id], (pass != NULL ? pass : ""));
+                       if (pass != NULL) {
+                               memset(pass, 0, strlen(pass));
+                       }
+                       g_free(pass);
 
                        curl = curl_easy_init();
                        curl_easy_setopt(curl, CURLOPT_URL, intf->url);
@@ -269,7 +273,7 @@ static void report_spam(gint id, ReportInterface *intf, MsgInfo *msginfo, gchar
                }
                break;
        default:
-               g_warning("Unknown method\n");
+               g_warning("Unknown method");
        }
        g_free(reqbody);
        g_free(geturl);