trustwords for same fpr now returns same fpr trustwords, not failure sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Thu, 23 Jan 2020 16:27:55 +0100
branchsync
changeset 43601ab2ccbf5f9f
parent 4358 0f4c24ab43b6
child 4361 f13151f0b577
trustwords for same fpr now returns same fpr trustwords, not failure
src/message_api.c
src/pEpEngine.c
test/src/TrustwordsTest.cc
     1.1 --- a/src/message_api.c	Tue Jan 21 15:11:58 2020 +0100
     1.2 +++ b/src/message_api.c	Thu Jan 23 16:27:55 2020 +0100
     1.3 @@ -4616,6 +4616,25 @@
     1.4              wsize, full);
     1.5  }
     1.6  
     1.7 +static void remove_separators(const char* str1, char* str2, int str1len) {
     1.8 +    int i = 0;
     1.9 +    char* curr_write = str2;
    1.10 +    for ( ; i < str1len; i++) {
    1.11 +        switch (str1[i]) {
    1.12 +            case ' ':
    1.13 +            case '\t':
    1.14 +            case '\r':
    1.15 +            case '\n':
    1.16 +            case '\0':
    1.17 +                continue;
    1.18 +            default:
    1.19 +                *curr_write = str1[i];
    1.20 +                curr_write++;
    1.21 +        }
    1.22 +    }
    1.23 +    *curr_write = '\0';
    1.24 +}
    1.25 +
    1.26  DYNAMIC_API PEP_STATUS get_trustwords_for_fprs(
    1.27          PEP_SESSION session, const char* fpr1, const char* fpr2,
    1.28          const char* lang, char **words, size_t *wsize, bool full
    1.29 @@ -4700,6 +4719,10 @@
    1.30      
    1.31      status = check_for_zero_fpr(XORed_fpr);
    1.32      
    1.33 +    if (status == PEP_TRUSTWORDS_DUPLICATE_FPR) {
    1.34 +        remove_separators(fpr1, XORed_fpr, fpr1_len);
    1.35 +        status = PEP_STATUS_OK;
    1.36 +    }
    1.37      if (status != PEP_STATUS_OK)
    1.38          goto error_release;
    1.39      
     2.1 --- a/src/pEpEngine.c	Tue Jan 21 15:11:58 2020 +0100
     2.2 +++ b/src/pEpEngine.c	Thu Jan 23 16:27:55 2020 +0100
     2.3 @@ -843,7 +843,6 @@
     2.4      // mean we should use it, and we should be *safe*, not relying 
     2.5      // on an implementation-specific quirk which might be sanely removed 
     2.6      // in a future sqlite version.
     2.7 -    stringpair_t* revoked_key_to_own_address = NULL;
     2.8      
     2.9      identity_list* id_list = NULL;
    2.10      status = own_identities_retrieve(session, &id_list);
     3.1 --- a/test/src/TrustwordsTest.cc	Tue Jan 21 15:11:58 2020 +0100
     3.2 +++ b/test/src/TrustwordsTest.cc	Thu Jan 23 16:27:55 2020 +0100
     3.3 @@ -150,19 +150,26 @@
     3.4      output_stream << "\nTest 2: fpr1 == fpr1, short" << endl;
     3.5  
     3.6      output_stream << "\nfinding French trustwords for " << fingerprint2 << "...\n";
     3.7 -    trustwords(session, fingerprint1.c_str(), "fr", &words1, &wsize1, 5);
     3.8 +    trustwords(session, fingerprint2.c_str(), "fr", &words1, &wsize1, 5);
     3.9      ASSERT_NE(words1, nullptr);
    3.10      output_stream << words1 << "\n";
    3.11  
    3.12      output_stream << "\nfinding French trustwords for " << identity2->address << " and " << identity2->address << "...\n";
    3.13      status = get_trustwords(session, identity2, identity2, "fr", &full_wordlist, &wsize_full, false);
    3.14 -    ASSERT_EQ(status , PEP_TRUSTWORDS_DUPLICATE_FPR);
    3.15 -    output_stream << "Discovered duplicate fprs as desired" << endl;
    3.16 +    ASSERT_STREQ(words1, full_wordlist);
    3.17 +    // ASSERT_EQ(status , PEP_TRUSTWORDS_DUPLICATE_FPR);
    3.18 +    // output_stream << "Discovered duplicate fprs as desired" << endl;
    3.19 +
    3.20 +    output_stream << "\nfinding English trustwords for " << fingerprint2 << "...\n";
    3.21 +    trustwords(session, fingerprint2.c_str(), "en", &words1, &wsize1, 5);
    3.22 +    ASSERT_NE(words1, nullptr);
    3.23 +    output_stream << words1 << "\n";
    3.24  
    3.25      output_stream << "\nfinding English trustwords for " << identity2->address << " and " << identity2->address << "... with spaces\n";
    3.26      get_trustwords(session, identity2, identity2_with_spaces, "en", &full_wordlist, &wsize_full, false);
    3.27 -    ASSERT_EQ(status , PEP_TRUSTWORDS_DUPLICATE_FPR);
    3.28 -    output_stream << "Discovered duplicate fprs as desired" << endl;
    3.29 +    ASSERT_STREQ(words1, full_wordlist);    
    3.30 +    // ASSERT_EQ(status , PEP_TRUSTWORDS_DUPLICATE_FPR);
    3.31 +    // output_stream << "Discovered duplicate fprs as desired" << endl;
    3.32  
    3.33      pEp_free(words1);
    3.34      words1 = nullptr;