forked from nfephp-org/sped-da
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sonar,danfe): atualiza geração de danfe de xml com caracteres inv…
…álidos
- Loading branch information
1 parent
50c7804
commit 6346f2e
Showing
1 changed file
with
8 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,6 +357,14 @@ public function __construct( | |
//se for passado o xml | ||
if (!empty($this->xml)) { | ||
$this->dom = new Dom(); | ||
|
||
// Remove caracteres não imprimíveis que podem quebrar a leitura do XML - @author Mathias Artur Schulz <[email protected]> (20-06-2024) | ||
// Tabela de conversão ASCII, decimal, hexadecimal, octal e binário: | ||
// https://www.ibm.com/docs/pt-br/aix/7.3?topic=adapters-ascii-decimal-hexadecimal-octal-binary-conversion-table | ||
// A linha abaixo ignora qualquer caractere com valor ASCII entre 0 e 31 (caracteres não imprimíveis) ou o caractere com valor ASCII 127 (DEL) | ||
// O modificador 'u' indica que estamos tratando o xml como UTF-8 | ||
$this->xml = preg_replace('/[\x00-\x1F\x7F]/u', '', $this->xml); | ||
|
||
$this->dom->loadXML($this->xml); | ||
$this->nfeProc = $this->dom->getElementsByTagName("nfeProc")->item(0); | ||
$this->infNFe = $this->dom->getElementsByTagName("infNFe")->item(0); | ||
|