Merged in dheeyi/processmaker/HOR-1733 (pull request #4842)

R-1733
This commit is contained in:
Julio Cesar Laura Avendaño
2016-08-31 11:57:35 -04:00
5 changed files with 24 additions and 10 deletions

View File

@@ -22,16 +22,16 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
if (! isset($_GET["file_hash"])) { if (!isset($_GET["file_hash"])) {
throw new Exception("Invalid Request, param 'file_hash' was not sent."); throw new Exception("Invalid Request, param 'file_hash' was not sent.");
} }
$httpStream = new \ProcessMaker\Util\IO\HttpStream(); $httpStream = new \ProcessMaker\Util\IO\HttpStream();
$outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP; $outputDir = PATH_DATA . "sites" . PATH_SEP . SYS_SYS . PATH_SEP . "files" . PATH_SEP . "output" . PATH_SEP;
$filename = base64_decode($_GET["file_hash"]); $filename = urldecode(base64_decode($_GET["file_hash"]));
$fileExtension = pathinfo($outputDir . $filename, PATHINFO_EXTENSION); $fileExtension = pathinfo($outputDir . $filename, PATHINFO_EXTENSION);
if (! file_exists($outputDir . $filename)) { if (!file_exists($outputDir . $filename)) {
throw new Exception("Error, couldn't find request file: $filename"); throw new Exception("Error, couldn't find request file: $filename");
} }

View File

@@ -10,7 +10,7 @@ class PMXPublisher
{ {
$parentDir = dirname($filename); $parentDir = dirname($filename);
if (! is_dir($parentDir)) { if (!is_dir($parentDir)) {
Util\Common::mk_dir($parentDir, 0775); Util\Common::mk_dir($parentDir, 0775);
} }
@@ -19,7 +19,12 @@ class PMXPublisher
file_put_contents($outputFile, $data); file_put_contents($outputFile, $data);
@chmod($outputFile, 0755); @chmod($outputFile, 0755);
return basename($outputFile); $currentLocale = setlocale(LC_CTYPE, 0);
setlocale(LC_CTYPE, 'en_US.UTF-8');
$filename = basename($outputFile);
setlocale(LC_CTYPE, $currentLocale);
return $filename;
} }
public function truncateName($outputFile, $dirName = true) public function truncateName($outputFile, $dirName = true)

View File

@@ -135,8 +135,13 @@ class XmlExporter extends Exporter
file_put_contents($outputFile, $this->export()); file_put_contents($outputFile, $this->export());
chmod($outputFile, 0755); chmod($outputFile, 0755);
return basename($outputFile); $currentLocale = setlocale(LC_CTYPE, 0);
setlocale(LC_CTYPE, 'en_US.UTF-8');
$filename = basename($outputFile);
setlocale(LC_CTYPE, $currentLocale);
return $filename;
} }
/** /**

View File

@@ -155,7 +155,7 @@ class HttpStream
*/ */
public function loadFromFile($filename) public function loadFromFile($filename)
{ {
if (! file_exists($filename)) { if (!file_exists($filename)) {
throw new \Exception("Unable to find file: $filename"); throw new \Exception("Unable to find file: $filename");
} }
@@ -163,7 +163,11 @@ class HttpStream
$this->content = file_get_contents($this->filename); $this->content = file_get_contents($this->filename);
$fileInfo = pathinfo($filename, PATHINFO_EXTENSION); $fileInfo = pathinfo($filename, PATHINFO_EXTENSION);
$this->setExtension($fileInfo); $this->setExtension($fileInfo);
$this->setSourceName(basename($filename)); $currentLocale = setlocale(LC_CTYPE, 0);
setlocale(LC_CTYPE, 'en_US.UTF-8');
$filename = basename($filename);
setlocale(LC_CTYPE, $currentLocale);
$this->setSourceName($filename);
} }
public function setExtension($extension) public function setExtension($extension)

View File

@@ -1127,7 +1127,7 @@ function exportProcess() {
myMask.hide(); myMask.hide();
if (result.success) { if (result.success) {
window.location = "../processes/processes_DownloadFile?file_hash=" + result.file_hash; window.location = "../processes/processes_DownloadFile?file_hash=" + encodeURIComponent(result.file_hash);
} else { } else {
Ext.Msg.show({ Ext.Msg.show({
title: "", title: "",