Merge pull request #11028 from turbo124/v5-develop

Improvements for template service parsing and appending xml segments …
This commit is contained in:
David Bomba 2025-06-03 12:58:14 +10:00 committed by GitHub
commit f4533421f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -205,7 +205,7 @@ class InvoiceService
return (new CreateRawPdf($invitation))->handle();
}
public function getInvoiceDeliveryNote(Invoice $invoice, \App\Models\ClientContact $contact = null)
public function getInvoiceDeliveryNote(Invoice $invoice, ?\App\Models\ClientContact $contact = null)
{
return (new GenerateDeliveryNote($invoice, $contact))->run();
}

View File

@ -354,7 +354,16 @@ class TemplateService
$f = $this->document->createDocumentFragment();
// $template = htmlspecialchars($template, ENT_XML1, 'UTF-8'); //2025-02-07 double encoding the entities = bad
$f->appendXML(str_ireplace("<br>", "<br/>", html_entity_decode($template)));
//2025-06-03 - we changed this to use CDATA INSTEAD so that we can support characters such as & when decoding.
//$f->appendXML(str_ireplace("<br>", "<br/>", html_entity_decode($template)));
$decoded_template = str_ireplace("<br>", "<br/>", html_entity_decode($template));
$f->appendXML('<![CDATA[' . $decoded_template . ']]>');
// Alternative solution: Proper XML escaping instead of CDATA
// $decoded_template = str_ireplace("<br>", "<br/>", html_entity_decode($template));
// $escaped_template = htmlspecialchars($decoded_template, ENT_XML1 | ENT_COMPAT, 'UTF-8');
// $f->appendXML($escaped_template);
$replacements[] = $f;