FIX #yogosha6907

This commit is contained in:
Laurent Destailleur 2021-08-17 13:08:03 +02:00
parent a31f991b39
commit 7d61609462
4 changed files with 15 additions and 13 deletions

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/core/lib/barcode.lib.php * \file htdocs/core/lib/barcode.lib.php
* \brief Set of functions used for barcode generation * \brief Set of functions used for barcode generation (internal lib, also code 'phpbarcode')
* \ingroup core * \ingroup core
*/ */
@ -69,7 +69,7 @@ if (defined('PHP-BARCODE_PATH_COMMAND')) {
* Print barcode * Print barcode
* *
* @param string $code Code * @param string $code Code
* @param string $encoding Encoding * @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...)
* @param integer $scale Scale * @param integer $scale Scale
* @param string $mode 'png' or 'jpg' ... * @param string $mode 'png' or 'jpg' ...
* @return array|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message * @return array|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message
@ -149,12 +149,10 @@ function barcode_encode($code, $encoding)
dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding); dol_syslog("barcode.lib.php::barcode_encode Use genbarcode ".$genbarcode_loc." code=".$code." encoding=".$encoding);
$bars = barcode_encode_genbarcode($code, $encoding); $bars = barcode_encode_genbarcode($code, $encoding);
} else { } else {
print "barcode_encode needs an external programm for encodings other then EAN/ISBN (code=".$code.", encoding=".$encoding.")<BR>\n"; print "barcode_encode needs an external program for encodings other then EAN/ISBN (code=".dol_escape_htmltag($code).", encoding=".dol_escape_htmltag($encoding).")<BR>\n";
print "<UL>\n"; print "<UL>\n";
print "<LI>download gnu-barcode from <A href=\"https://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n"; print "<LI>download gnu-barcode from <A href=\"https://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</A>\n";
print "<LI>compile and install them\n"; print "<LI>compile and install them\n";
print "<LI>download genbarcode from <A href=\"http://www.ashberg.de/bar/\">www.ashberg.de/bar/</A>\n";
print "<LI>compile and install them\n";
print "<LI>specify path the genbarcode in barcode module setup\n"; print "<LI>specify path the genbarcode in barcode module setup\n";
print "</UL>\n"; print "</UL>\n";
print "<BR>\n"; print "<BR>\n";

View File

@ -20,7 +20,7 @@
/** /**
* \file htdocs/core/modules/barcode/doc/phpbarcode.modules.php * \file htdocs/core/modules/barcode/doc/phpbarcode.modules.php
* \ingroup barcode * \ingroup barcode
* \brief File with class to generate barcode images using php barcode generator * \brief File with class to generate barcode images using php internal lib barcode generator
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
@ -126,7 +126,7 @@ class modPhpbarcode extends ModeleBarCode
* *
* @param string $code Value to encode * @param string $code Value to encode
* @param string $encoding Mode of encoding * @param string $encoding Mode of encoding
* @param string $readable Code can be read * @param string $readable Code can be read (What is this ? is this used ?)
* @param integer $scale Scale * @param integer $scale Scale
* @param integer $nooutputiferror No output if error * @param integer $nooutputiferror No output if error
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -163,7 +163,7 @@ class modPhpbarcode extends ModeleBarCode
if (!is_array($result)) { if (!is_array($result)) {
$this->error = $result; $this->error = $result;
if (empty($nooutputiferror)) { if (empty($nooutputiferror)) {
print $this->error; print dol_escape_htmltag($this->error);
} }
return -1; return -1;
} }

View File

@ -100,7 +100,7 @@ class modTcpdfbarcode extends ModeleBarCode
* *
* @param string $code Value to encode * @param string $code Value to encode
* @param string $encoding Mode of encoding * @param string $encoding Mode of encoding
* @param string $readable Code can be read * @param string $readable Code can be read (What is this ? is this used ?)
* @param integer $scale Scale (not used with this engine) * @param integer $scale Scale (not used with this engine)
* @param integer $nooutputiferror No output if error (not used with this engine) * @param integer $nooutputiferror No output if error (not used with this engine)
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK

View File

@ -282,10 +282,14 @@ if (preg_match('/\.\./', $fullpath_original_file) || preg_match('/[<>|]/', $full
if ($modulepart == 'barcode') { if ($modulepart == 'barcode') {
$generator = GETPOST("generator", "alpha"); $generator = GETPOST("generator", "aZ09");
$code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...) $encoding = GETPOST("encoding", "aZ09");
$encoding = GETPOST("encoding", "alpha"); $readable = GETPOST("readable", 'aZ09') ? GETPOST("readable", "aZ09") : "Y";
$readable = GETPOST("readable", 'alpha') ?GETPOST("readable", "alpha") : "Y"; if (in_array($encoding, array('EAN8', 'EAN13'))) {
$code = GETPOST("code", 'alphanohtml');
} else {
$code = GETPOST("code", 'none'); // This can be rich content (qrcode, datamatrix, ...)
}
if (empty($generator) || empty($encoding)) { if (empty($generator) || empty($encoding)) {
print 'Error: Parameter "generator" or "encoding" not defined'; print 'Error: Parameter "generator" or "encoding" not defined';