Index: branches/5.2.x/core/units/helpers/deployment_helper.php
===================================================================
diff -u -N -r15137 -r15332
--- branches/5.2.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 15137)
+++ branches/5.2.x/core/units/helpers/deployment_helper.php (.../deployment_helper.php) (revision 15332)
@@ -1,6 +1,6 @@
Application->recallObject('LanguageImportHelper');
/* @var $language_import_helper LanguageImportHelper */
- echo 'Importing LanguagePack ... ';
+ $this->out('Importing LanguagePack ... ');
$filename = $this->getModuleFile('english.lang');
$language_import_helper->performImport($filename, '|0|1|2|', $this->moduleName, LANG_SKIP_EXISTING);
$this->displayStatus('OK');
@@ -242,12 +242,12 @@
private function resetCaches()
{
// 2. reset unit config cache (so new classes get auto-registered)
- echo 'Resetting Unit Config Cache ... ';
+ $this->out('Resetting Unit Config Cache ... ');
$this->Application->HandleEvent(new kEvent('adm:OnResetConfigsCache'));
$this->displayStatus('OK');
// 3. reset sections cache
- echo 'Resetting Sections Cache ... ';
+ $this->out('Resetting Sections Cache ... ');
$this->Application->HandleEvent(new kEvent('adm:OnResetSections'));
$this->displayStatus('OK');
}
@@ -260,7 +260,7 @@
*/
private function refreshThemes()
{
- echo 'Rebuilding Theme Files ... ';
+ $this->out('Rebuilding Theme Files ... ');
$this->Application->HandleEvent(new kEvent('adm:OnRebuildThemes'));
$this->displayStatus('OK');
}
@@ -276,7 +276,7 @@
$this->loadAppliedRevisions();
$this->Conn->errorHandler = Array (&$this, 'handleSqlError');
- echo 'Verifying Database Revisions ... ';
+ $this->out('Verifying Database Revisions ... ');
if ( !$this->collectDatabaseRevisions() || !$this->checkRevisionDependencies() ) {
return false;
@@ -403,7 +403,7 @@
return true;
}
- echo 'Upgrading Database ... ' . PHP_EOL;
+ $this->out('Upgrading Database ... ', true);
foreach ($this->revisionSqls as $revision => $sqls) {
echo PHP_EOL . $this->colorText($this->revisionTitles[$revision], 'gray', true) . PHP_EOL; // 'Processing DB Revision: #' . $revision . ' ... ';
@@ -423,7 +423,7 @@
}
elseif ( $sql ) {
$this->toLog($sql . ' ... ', false);
- echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', $sql)), 0, self::SQL_TRIM_LENGTH) . ' ... ';
+ echo mb_substr(trim(preg_replace('/(\n|\t| )+/is', ' ', ($this->isCommandLine ? $sql : htmlspecialchars($sql)))), 0, self::SQL_TRIM_LENGTH) . ' ... ';
$this->Conn->Query($sql);
@@ -462,7 +462,7 @@
$this->toLog('FAILED' . PHP_EOL . 'SQL Error #' . $code . ': ' . $msg);
$this->displayStatus('FAILED' . PHP_EOL . 'SQL Error #' . $code . ': ' . $msg);
- echo 'Please execute rest of SQLs in this Revision by hand and run deployment script again.' . PHP_EOL;
+ $this->out('Please execute rest of SQLs in this Revision by hand and run deployment script again.', true);
return true;
}
@@ -564,7 +564,7 @@
$html_color = $html_color_map[$color][$bold ? 'bold' : 'normal'];
- return '' . $text . '';
+ return '' . htmlspecialchars($text) . '';
}
/**
@@ -580,7 +580,7 @@
return "\033[1m" . $text . "\033[0m";
}
- return '' . $text . '';
+ return '' . htmlspecialchars($text) . '';
}
/**
@@ -601,4 +601,20 @@
echo PHP_EOL;
}
}
+
+ /**
+ * Outputs a text and escapes it if necessary
+ *
+ * @param string $text
+ * @param bool $new_line
+ * @return void
+ */
+ private function out($text, $new_line = false)
+ {
+ if ( !$this->isCommandLine ) {
+ $text = htmlspecialchars($text);
+ }
+
+ echo $text . ($new_line ? PHP_EOL : '');
+ }
}
\ No newline at end of file