make valid filenames

This commit is contained in:
Daniel Seifert 2020-06-17 09:05:49 +02:00
parent a6e09a7f95
commit 471d78986f
3 changed files with 27 additions and 11 deletions

View File

@ -199,10 +199,18 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
{ {
// forced filename from setFilename() // forced filename from setFilename()
if ($this->filename) { if ($this->filename) {
return $this->addFilenameExtension($this->filename); return $this->addFilenameExtension(
$this->makeValidFileName(
$this->filename
)
);
} }
return $this->addFilenameExtension($this->getTypeForFilename()); return $this->addFilenameExtension(
$this->makeValidFileName(
$this->getTypeForFilename()
)
);
} }
/** /**

View File

@ -69,19 +69,25 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
{ {
// forced filename from setFilename() // forced filename from setFilename()
if ($this->filename) { if ($this->filename) {
return $this->addFilenameExtension($this->filename); return $this->addFilenameExtension(
$this->makeValidFileName(
$this->filename
)
);
} }
$sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname')); $sTrimmedBillName = trim($this->getOrder()->getFieldData('oxbilllname'));
return $this->addFilenameExtension( return $this->addFilenameExtension(
implode( $this->makeValidFileName(
'_', implode(
[ '_',
$this->getTypeForFilename(), [
$this->getOrder()->getFieldData('oxordernr'), $this->getTypeForFilename(),
$sTrimmedBillName $this->getOrder()->getFieldData('oxordernr'),
] $sTrimmedBillName
]
)
) )
); );
} }

View File

@ -111,10 +111,12 @@ class invoicePdf extends pdfdocumentsOrder implements pdfdocumentsOrderinvoiceIn
{ {
$filename = parent::getFilename(); $filename = parent::getFilename();
return str_replace( $filename = str_replace(
$this->getOrder()->getFieldData('oxordernr'), $this->getOrder()->getFieldData('oxordernr'),
$this->getOrder()->getFieldData('oxbillnr'), $this->getOrder()->getFieldData('oxbillnr'),
$filename $filename
); );
return $this->makeValidFileName($filename);
} }
} }