tecnickcom / TCPDF

Official clone of PHP library to generate PDF documents and barcodes
https://tcpdf.org
Other
4.22k stars 1.52k forks source link

Undefined array key 26085 in tcpdf.php line 22263 #580

Open liayn opened 1 year ago

liayn commented 1 year ago

version 6.6.1

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

williamdes commented 1 year ago

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

liayn commented 1 year ago

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') {

williamdes commented 1 year ago

Okay

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

liayn commented 1 year ago

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

williamdes commented 1 year ago

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

liayn commented 1 year ago

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)

williamdes commented 1 year ago

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

annuh commented 8 months ago

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.