text stringlengths 0 357 |
|---|
if (colon) { |
*colon = 0; |
} |
addr = dc_strdup(payload); |
} |
else if (strncasecmp(qr, MATMSG_SCHEME, strlen(MATMSG_SCHEME))==0) |
{ |
/* scheme: `MATMSG:TO:addr...;SUB:subject...;BODY:body...;` - there may or may not be linebreaks after the fields */ |
char* to = strstr(qr, "TO:"); /* does not work when the text `TO:` is used in subject/body _and_ TO: is not the first field. we ignore this case. */ |
if (to) { |
addr = dc_strdup(&to[3]); |
char* semicolon = strchr(addr, ';'); |
if (semicolon) { *semicolon = 0; } |
} |
else { |
qr_parsed->state = DC_QR_ERROR; |
qr_parsed->text1 = dc_strdup("Bad e-mail address."); |
goto cleanup; |
} |
} |
else if (strncasecmp(qr, VCARD_BEGIN, strlen(VCARD_BEGIN))==0) |
{ |
/* scheme: `VCARD:BEGIN\nN:last name;first name;...;\nEMAIL:addr...;` */ |
carray* lines = dc_split_into_lines(qr); |
for (int i = 0; i < carray_count(lines); i++) { |
char* key = (char*)carray_get(lines, i); dc_trim(key); |
char* value = strchr(key, ':'); |
if (value) { |
*value = 0; |
value++; |
char* semicolon = strchr(key, ';'); if (semicolon) { *semicolon = 0; } /* handle `EMAIL;type=work:` stuff */ |
if (strcasecmp(key, "EMAIL")==0) { |
semicolon = strchr(value, ';'); if (semicolon) { *semicolon = 0; } /* use the first EMAIL */ |
addr = dc_strdup(value); |
} |
else if (strcasecmp(key, "N")==0) { |
semicolon = strchr(value, ';'); if (semicolon) { semicolon = strchr(semicolon+1, ';'); if (semicolon) { *semicolon = 0; } } /* the N format is `lastname;prename;wtf;title` - skip everything after the second semicolon */ |
name = dc_strdup(value); |
dc_str_replace(&name, ";", ","); /* the format "lastname,prename" is handled by dc_normalize_name() */ |
dc_normalize_name(name); |
} |
} |
} |
dc_free_splitted_lines(lines); |
} |
/* check the paramters |
---------------------- */ |
if (addr) { |
char* temp = dc_urldecode(addr); free(addr); addr = temp; /* urldecoding is needed at least for OPENPGP4FPR but should not hurt in the other cases */ |
temp = dc_addr_normalize(addr); free(addr); addr = temp; |
if (!dc_may_be_valid_addr(addr)) { |
qr_parsed->state = DC_QR_ERROR; |
qr_parsed->text1 = dc_strdup("Bad e-mail address."); |
goto cleanup; |
} |
} |
if (fingerprint) { |
if (strlen(fingerprint) != 40) { |
qr_parsed->state = DC_QR_ERROR; |
qr_parsed->text1 = dc_strdup("Bad fingerprint length in QR code."); |
goto cleanup; |
} |
} |
/* let's see what we can do with the parameters |
---------------------------------------------- */ |
if (fingerprint) |
{ |
/* fingerprint set ... */ |
if (addr==NULL || invitenumber==NULL || auth==NULL) |
{ |
// _only_ fingerprint set ... |
// (we could also do this before/instead of a secure-join, however, this may require complicated questions in the ui) |
if (dc_apeerstate_load_by_fingerprint(peerstate, context->sql, fingerprint)) { |
qr_parsed->state = DC_QR_FPR_OK; |
qr_parsed->id = dc_add_or_lookup_contact(context, NULL, peerstate->addr, DC_ORIGIN_UNHANDLED_QR_SCAN, NULL); |
dc_create_or_lookup_nchat_by_contact_id(context, qr_parsed->id, DC_CHAT_DEADDROP_BLOCKED, &chat_id, NULL); |
device_msg = dc_mprintf("%s verified.", peerstate->addr); |
} |
else { |
qr_parsed->text1 = dc_format_fingerprint(fingerprint); |
qr_parsed->state = DC_QR_FPR_WITHOUT_ADDR; |
} |
} |
else |
{ |
// fingerprint + addr set, secure-join requested |
// do not comapre the fingerprint already - it may have changed - errors are catched later more proberly. |
// (theroretically, there is also the state "addr=set, fingerprint=set, invitenumber=0", however, currently, we won't get into this state) |
if (grpid && grpname) { |
qr_parsed->state = DC_QR_ASK_VERIFYGROUP; |
qr_parsed->text1 = dc_strdup(grpname); |
qr_parsed->text2 = dc_strdup(grpid); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.