...
authorVolker Birk <vb@pep-project.org>
Mon, 30 Mar 2015 14:59:34 +0200
changeset 165f0894860af4a
parent 164 bc618bca4300
child 166 fefff48448e3
...
src/etpan_mime.c
test/Makefile
test/message_api_test.cc
test/mime_test.cc
     1.1 --- a/src/etpan_mime.c	Mon Mar 30 07:35:11 2015 +0200
     1.2 +++ b/src/etpan_mime.c	Mon Mar 30 14:59:34 2015 +0200
     1.3 @@ -646,8 +646,8 @@
     1.4      for (cur = clist_begin(list); cur != NULL ; cur = clist_next(cur)) {
     1.5          struct mailmime_parameter * param = clist_content(cur);
     1.6          if (param &&
     1.7 -                param->pa_name && strcmp(name, param->pa_name) == 0 &&
     1.8 -                param->pa_value && strcmp(value, param->pa_value) == 0)
     1.9 +                param->pa_name && strcasecmp(name, param->pa_name) == 0 &&
    1.10 +                param->pa_value && strcasecmp(value, param->pa_value) == 0)
    1.11              return true;
    1.12      }
    1.13  
    1.14 @@ -665,7 +665,7 @@
    1.15              MAILMIME_COMPOSITE_TYPE_MULTIPART) {
    1.16          if (subtype)
    1.17              return content->ct_subtype &&
    1.18 -                    strcmp(content->ct_subtype, subtype) == 0;
    1.19 +                    strcasecmp(content->ct_subtype, subtype) == 0;
    1.20          else
    1.21              return true;
    1.22      }
    1.23 @@ -696,7 +696,7 @@
    1.24              MAILMIME_DISCRETE_TYPE_TEXT) {
    1.25          if (subtype)
    1.26              return content->ct_subtype &&
    1.27 -                    strcmp(content->ct_subtype, subtype) == 0;
    1.28 +                    strcasecmp(content->ct_subtype, subtype) == 0;
    1.29          else
    1.30              return true;
    1.31      }
    1.32 @@ -765,7 +765,7 @@
    1.33              for (cur = clist_begin(content->ct_parameters); cur; cur =
    1.34                      clist_next(cur)) {
    1.35                  struct mailmime_parameter * param = clist_content(cur);
    1.36 -                if (param && param->pa_name && strcmp(param->pa_name,
    1.37 +                if (param && param->pa_name && strcasecmp(param->pa_name,
    1.38                              "charset") == 0) {
    1.39                      _charset = param->pa_value;
    1.40                      break;
     2.1 --- a/test/Makefile	Mon Mar 30 07:35:11 2015 +0200
     2.2 +++ b/test/Makefile	Mon Mar 30 14:59:34 2015 +0200
     2.3 @@ -18,7 +18,7 @@
     2.4  .PHONY: clean
     2.5  
     2.6  clean:
     2.7 -	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS)
     2.8 +	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf
     2.9  
    2.10  test: pEpEngineTest
    2.11  	LD_LIBRARY_PATH=~/lib:../src ./pEpEngineTest
     3.1 --- a/test/message_api_test.cc	Mon Mar 30 07:35:11 2015 +0200
     3.2 +++ b/test/message_api_test.cc	Mon Mar 30 14:59:34 2015 +0200
     3.3 @@ -1,4 +1,6 @@
     3.4 +#include "platform.h"
     3.5  #include <iostream>
     3.6 +#include <fstream>
     3.7  #include <assert.h>
     3.8  #include "message_api.h"
     3.9  
    3.10 @@ -53,10 +55,16 @@
    3.11      message *msg3;
    3.12      PEP_STATUS status3 = mime_decode_message(text2, &msg3);
    3.13      assert(status3 == PEP_STATUS_OK);
    3.14 +    string string3 = text2;
    3.15 +    free(text2);
    3.16 +
    3.17 +    unlink("msg4.asc");
    3.18 +    ofstream outFile3("msg4.asc");
    3.19 +    outFile3.write(string3.c_str(), string3.size());
    3.20 +    outFile3.close();
    3.21  
    3.22      cout << "freeing messages…\n";
    3.23      free_message(msg3);
    3.24 -    free(text2);
    3.25      free_message(msg2);
    3.26      free_message(enc_msg2);
    3.27      cout << "done.\n";
     4.1 --- a/test/mime_test.cc	Mon Mar 30 07:35:11 2015 +0200
     4.2 +++ b/test/mime_test.cc	Mon Mar 30 14:59:34 2015 +0200
     4.3 @@ -9,6 +9,47 @@
     4.4  
     4.5  using namespace std;
     4.6  
     4.7 +void test_mime_decoding(string filename) {
     4.8 +    cout << "opening " << filename << " for reading\n";
     4.9 +    ifstream inFile3 (filename);
    4.10 +    assert(inFile3.is_open());
    4.11 +
    4.12 +    string mimetext3;
    4.13 +
    4.14 +    cout << "reading mime sample\n";
    4.15 +    while (!inFile3.eof()) {
    4.16 +        static string line;
    4.17 +        getline(inFile3, line);
    4.18 +        mimetext3 += line + "\n";
    4.19 +    }
    4.20 +    inFile3.close();
    4.21 +
    4.22 +    cout << "decoding message…\n";
    4.23 +    message *msg3;
    4.24 +    PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), &msg3);
    4.25 +    assert(status3 == PEP_STATUS_OK);
    4.26 +    assert(msg3);
    4.27 +    cout << "decoded.\n\n";
    4.28 +    cout << "Subject: " << msg3->shortmsg << "\n\n";
    4.29 +    if (msg3->longmsg)
    4.30 +        cout << msg3->longmsg << "\n\n";
    4.31 +    if (msg3->longmsg_formatted)
    4.32 +        cout << msg3->longmsg_formatted << "\n\n";
    4.33 +    bloblist_t *_b;
    4.34 +    for (_b = msg3->attachments; _b; _b = _b->next) {
    4.35 +        cout << "attachment of type " << _b->mime_type << "\n";
    4.36 +        if (_b->filename) {
    4.37 +            cout << "filename: " << _b->filename << "\n";
    4.38 +            unlink(_b->filename);
    4.39 +            ofstream outFile3(_b->filename);
    4.40 +            outFile3.write(_b->data, _b->size);
    4.41 +            outFile3.close();
    4.42 +        }
    4.43 +    }
    4.44 +
    4.45 +    free_message(msg3);
    4.46 +}
    4.47 +
    4.48  int main() {
    4.49      cout << "\n*** mime_test ***\n\n";
    4.50  
    4.51 @@ -47,44 +88,9 @@
    4.52      free(result2);
    4.53      free_message(msg2);
    4.54  
    4.55 -    cout << "opening mime_sample.txt for reading\n";
    4.56 -    ifstream inFile3 ("mime_sample.txt");
    4.57 -    assert(inFile3.is_open());
    4.58 -
    4.59 -    string mimetext3;
    4.60 -
    4.61 -    cout << "reading mime sample\n";
    4.62 -    while (!inFile3.eof()) {
    4.63 -        static string line;
    4.64 -        getline(inFile3, line);
    4.65 -        mimetext3 += line + "\n";
    4.66 -    }
    4.67 -    inFile3.close();
    4.68 -
    4.69 -    cout << "decoding message…\n";
    4.70 -    message *msg3;
    4.71 -    PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), &msg3);
    4.72 -    assert(status3 == PEP_STATUS_OK);
    4.73 -    assert(msg3);
    4.74 -    cout << "decoded.\n\n";
    4.75 -    cout << "Subject: " << msg3->shortmsg << "\n\n";
    4.76 -    if (msg3->longmsg)
    4.77 -        cout << msg3->longmsg << "\n\n";
    4.78 -    if (msg3->longmsg_formatted)
    4.79 -        cout << msg3->longmsg_formatted << "\n\n";
    4.80 -    bloblist_t *_b;
    4.81 -    for (_b = msg3->attachments; _b; _b = _b->next) {
    4.82 -        cout << "attachment of type " << _b->mime_type << "\n";
    4.83 -        if (_b->filename) {
    4.84 -            cout << "filename: " << _b->filename << "\n";
    4.85 -            unlink(_b->filename);
    4.86 -            ofstream outFile3(_b->filename);
    4.87 -            outFile3.write(_b->data, _b->size);
    4.88 -            outFile3.close();
    4.89 -        }
    4.90 -    }
    4.91 -
    4.92 -    free_message(msg3);
    4.93 +    test_mime_decoding("msg1.asc");
    4.94 +    test_mime_decoding("msg2.asc");
    4.95 +    test_mime_decoding("msg3.asc");
    4.96  
    4.97      cout << "calling release()\n";
    4.98      release(session);