# Remove debug_print_backtrace(), which can leak system details. Put backtrace in log.
simple_replace vendor/dompdf/dompdf/lib/html5lib/TreeBuilder.php 'debug_print_backtrace();' 'CRM_Core_Error::backtrace("backTrace", TRUE);'
-patch vendor/dompdf/dompdf/src/Dompdf.php < tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch
+if ! grep -q 'CRM-21395' vendor/dompdf/dompdf/src/Dompdf.php; then
+ patch vendor/dompdf/dompdf/src/Dompdf.php < tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch
+fi
$doc->loadHTML($str);
$doc->encoding = $encoding;
-+ // Remove #text children nodes in nodes that shouldn't have
++ // Remove #text children nodes in nodes that shouldn't have #CRM-21395
+ $tag_names = array("html", "table", "tbody", "thead", "tfoot", "tr");
+ foreach ($tag_names as $tag_name) {
+ $nodes = $doc->getElementsByTagName($tag_name);