Skip to content

Commit

Permalink
ndef: return not implemented for utf16 on ndef text
Browse files Browse the repository at this point in the history
since noone has discovered how broken this has been since 2012 just
return not yet implemented.
  • Loading branch information
klali committed Sep 21, 2020
1 parent 8f28219 commit 5c991c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tests/test_ndef_construction.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ static void _test_other_lang_text(void)
YK_NDEF *ndef = ykp_alloc_ndef();
char text[] = "aaaaaaaaaaaaaaa";
size_t text_len = strlen(text);
int rc = ykp_construct_ndef_text(ndef, text, "sv-SE", true);
char text2[256];
int rc = ykp_construct_ndef_text(ndef, text, "sv-SE", false);
char text2[256] = {0};
assert(rc == 1);
assert(ndef->type == 'T');
assert(ndef->data[0] == (0x80 & 5));
assert(ndef->data[0] == (5));
assert(memcmp(ndef->data + 1, "sv-SE", 5) == 0);
assert(memcmp(ndef->data + 6, text, text_len) == 0);
assert(ndef->len == text_len + 6);
rc = ykp_ndef_as_text(ndef, text2, 256);
assert(rc == 1);
assert(memcmp(text, text2, strlen(text)));
assert(memcmp(text, text2, strlen(text)) == 0);
ykp_free_ndef(ndef);
}

Expand Down
3 changes: 2 additions & 1 deletion ykpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ int ykp_construct_ndef_text(YK_NDEF *ndef, const char *text, const char *lang, b
size_t lang_length = strlen(lang);
unsigned char status = lang_length;
if(isutf16) {
status &= 0x80;
ykp_errno = YKP_ENOTYETIMPL;
return 0;
}
if((data_length + lang_length + 1) > NDEF_DATA_SIZE) {
ykp_errno = YKP_EINVAL;
Expand Down

0 comments on commit 5c991c1

Please sign in to comment.