lsnepomuceno / laravel-a1-pdf-sign

Sign PDF files with valid x509 certificate
https://laravel-a1-pdf-sign.netlify.app/
MIT License
283 stars 54 forks source link

Fix: Obtain certificate info when "," contained inside Quotation marks. #108

Closed celli33 closed 1 year ago

celli33 commented 1 year ago

When comma is found inside certificate data the function LSNepomuceno\LaravelA1PdfSign\Sign\ValidatePdfSignature::processDataToInfo throws an Undefined array key 1 because of:

$data = explode(', ', $data);

It can be removed by using preg_split like:

/** it allows to split  by "," except when "," inside of quoutes */
$data = preg_split('/\s*,\s*(?=(?:[^"]*"[^"]*")*[^"]*$)/', trim($data));

For example:

$data = "emailAddress = contacto.tecnico@example.com, street = "AV. HIDALGO 77, COL. GUERRERO", postalCode = 06300"

the function: explode(", ", $data) will return and array separated in [["street" => "AV. HIDALGO 77"], [" COL. GUERRERO"]].

When expected is: [["street" => "AV. HIDALGO 77, COL. GUERRERO"]]

This PR closes #101

lsnepomuceno commented 1 year ago

Hello @celli33 ,

This PR is of great help, thank you for the support.

A new version of the package will be released on August 4th with its fix.

Thanks in advance.