TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

Undefined array key 26085 in tcpdf.php line 22263

Open liayn opened this issue 2 years ago • 8 comments

version 6.6.1

affected line: if ((!$intag) AND (!$skip) AND TCPDF_FONT_DATA::$uni_type[$char] == 'L') {

liayn avatar Jan 11 '23 15:01 liayn

Can you provide some code on how you trigger this? Or the full stack trace?

williamdes avatar Jan 11 '23 15:01 williamdes

I'm sorry, no. We just found it in the logs. I can try to reproduce, but I suspect a case, where a really large dataset is used to create PDF. But the fix is trivial: if ((!$intag) AND (!$skip) AND (TCPDF_FONT_DATA::$uni_type[$char] ?? '') == 'L') {

liayn avatar Jan 11 '23 15:01 liayn

Okay

Yeah and using isset because ?? is php 7+ only haha

williamdes avatar Jan 11 '23 15:01 williamdes

I'm totally fine with a tcpdf v7 that is php8.1+ only. php v7 is dead already... so that's it

liayn avatar Jan 11 '23 15:01 liayn

Yeah but welcome to the long long term support We support php 5.3 up to 8.2 here

williamdes avatar Jan 11 '23 16:01 williamdes

I know long term... no worries. But for the sake of dev piece and invention stagnation avoidance we usually split into to versions for legacy and current stuff. In TCPDF case this would be 8.x and anything below. (This issue only happens on 8.x anyway)

liayn avatar Jan 11 '23 16:01 liayn

Thanks for reporting this issue, we will try to reproduce it because tests are important and fix it

williamdes avatar Jan 11 '23 16:01 williamdes

We are facing the same issue, for example when adding this text to a PDF 斯 لارس:

Warning: Undefined array key 25289

#0 /var/task/vendor/tecnickcom/tcpdf/tcpdf.php(4113): TCPDF_FONTS::utf8Bidi(Array, '\\xE6\\x8B\\x89\\xE7\\x88\\xBE\\xE6...', false, true, Array)",
#1 /var/task/vendor/tecnickcom/tcpdf/tcpdf.php(18523): TCPDF->GetStringWidth('\\xE6\\x8B\\x89\\xE7\\x88\\xBE\\xE6...')",
#2 /var/task/vendor/tecnickcom/tcpdf/tcpdf.php(5934): TCPDF->writeHTML('    <p style=\"f...', true, false, true, true, '')",
#3 /var/task/vendor/tecnickcom/tcpdf/tcpdf.php(17261): TCPDF->MultiCell(64.249217935349, 0, '    <p style=\"f...', 1, '', false, 0, 0, 0.0, true, 0, true, true, 0, 'T', false)",

It seems some Unicode characters are missing from this list https://github.com/tcpdf-clone/tcpdf/blob/master/include/tcpdf_font_data.php#L10617.

We are using v6.6.5.

annuh avatar Mar 14 '24 12:03 annuh