diff --git a/lib/documentmanagement/documentmetadataversion.inc.php b/lib/documentmanagement/documentmetadataversion.inc.php
index 12ed6d9..0d39e50 100644
--- a/lib/documentmanagement/documentmetadataversion.inc.php
+++ b/lib/documentmanagement/documentmetadataversion.inc.php
@@ -95,8 +95,8 @@ class KTDocumentMetadataVersion extends KTEntity {
function setContentVersion($iNewValue) { $this->iContentVersion = $iNewValue; }
function getDocumentTypeId() { return $this->iDocumentTypeId; }
function setDocumentTypeId($iNewValue) { $this->iDocumentTypeId = $iNewValue; }
- function getName() { return $this->sName; }
- function setName($sNewValue) { $this->sName = $sNewValue; }
+ function getName() { return sanitizeForSQLtoHTML($this->sName); }
+ function setName($sNewValue) { $this->sName = sanitizeForSQL($sNewValue); }
function getDescription() { return $this->sDescription; }
function setDescription($sNewValue) { $this->sDescription = $sNewValue; }
function getStatusId() { return $this->iStatusId; }
diff --git a/lib/sanitize.inc b/lib/sanitize.inc
deleted file mode 100644
index ae283f3..0000000
--- a/lib/sanitize.inc
+++ /dev/null
@@ -1,53 +0,0 @@
-
diff --git a/lib/util/sanitize.inc b/lib/util/sanitize.inc
index e8b7b1c..96a169b 100644
--- a/lib/util/sanitize.inc
+++ b/lib/util/sanitize.inc
@@ -52,11 +52,12 @@ function sanitize($string) {
function sanitizeForSQL($string, $min='', $max='') {
+ $string = trim($string);
+ if(get_magic_quotes_gpc()) $string = stripslashes($string);
+
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
- if(get_magic_quotes_gpc()) $string = stripslashes($string);
-
if(function_exists("mysql_real_escape_string")) {
return mysql_real_escape_string($string);
} else {
@@ -64,38 +65,54 @@ function sanitizeForSQL($string, $min='', $max='') {
}
}
+function sanitizeForSQLtoHTML($string, $min='', $max='') {
+
+ return stripslashes(trim($string));
+
+}
+
function sanitizeForHTML($string, $min='', $max='')
{
+ $string = trim($string);
+ if(get_magic_quotes_gpc()) $string = stripslashes($string);
+
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
- $pattern[0] = '/\&/';
- $pattern[1] = '/';
- $pattern[2] = "/>/";
- $pattern[3] = '/\n/';
- $pattern[4] = '/"/';
- $pattern[5] = "/'/";
- $pattern[6] = "/%/";
- $pattern[7] = '/\( /';
- $pattern[8] = '/\)/';
- $pattern[9] = '/\+/';
- $pattern[10] = '/-/';
- $replacement[0] = '&';
- $replacement[1] = '<';
- $replacement[2] = '>';
- $replacement[3] = '
';
- $replacement[4] = '"';
- $replacement[5] = ''';
- $replacement[6] = '%';
- $replacement[7] = '(';
- $replacement[8] = ')';
- $replacement[9] = '+';
- $replacement[10] = '-';
- return preg_replace( $pattern, $replacement, $string);
+ if(function_exists("htmlspecialchars")) {
+ return htmlspecialchars($string);
+ } else {
+ $pattern[0] = '/\&/';
+ $pattern[1] = '/';
+ $pattern[2] = "/>/";
+ $pattern[3] = '/\n/';
+ $pattern[4] = '/"/';
+ $pattern[5] = "/'/";
+ $pattern[6] = "/%/";
+ $pattern[7] = '/\( /';
+ $pattern[8] = '/\)/';
+ $pattern[9] = '/\+/';
+ $pattern[10] = '/-/';
+ $replacement[0] = '&';
+ $replacement[1] = '<';
+ $replacement[2] = '>';
+ $replacement[3] = '
';
+ $replacement[4] = '"';
+ $replacement[5] = ''';
+ $replacement[6] = '%';
+ $replacement[7] = '(';
+ $replacement[8] = ')';
+ $replacement[9] = '+';
+ $replacement[10] = '-';
+ return preg_replace( $pattern, $replacement, $string);
+ }
}
function sanitizeForSYSTEM($string, $min='', $max='')
{
+ $string = trim($string);
+ if(get_magic_quotes_gpc()) $string = stripslashes($string);
+
$len = strlen($string);
if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return false;
diff --git a/plugins/ktcore/document/edit.php b/plugins/ktcore/document/edit.php
index dd6863f..f854ebc 100644
--- a/plugins/ktcore/document/edit.php
+++ b/plugins/ktcore/document/edit.php
@@ -96,7 +96,7 @@ class KTDocumentEditAction extends KTDocumentAction {
'description' => sprintf(_kt("The document title is used as the main name of a document throughout %s™."), APP_NAME),
'name' => 'document_title',
'required' => true,
- 'value' => $this->oDocument->getName(),
+ 'value' => sanitizeForHTML($this->oDocument->getName()),
)),
);
$validators = array(
@@ -191,7 +191,8 @@ class KTDocumentEditAction extends KTDocumentAction {
if ($this->oDocument->getDocumentTypeId() != $doctypeid) {
$this->oDocument->setDocumentTypeId($doctypeid);
}
- $this->oDocument->setName(sanitize($data['document_title']));
+ $this->oDocument->setName(($data['document_title']));
+
$res = $this->oDocument->update();
if (PEAR::isError($res)) {
$oForm->handleError(sprintf(_kt("Unexpected failure to update document title: %s"), $res->getMessage()));
diff --git a/templates/kt3/document/view.smarty b/templates/kt3/document/view.smarty
index 39d321a..ef1a4e8 100644
--- a/templates/kt3/document/view.smarty
+++ b/templates/kt3/document/view.smarty
@@ -1,6 +1,5 @@
{i18n}The following files are present in the repository, but do not exist in the database.{/i18n}:
{i18n arg_link=$link arg_name=$type_name}Change the document type. The current type is "#name#"{/i18n}
diff --git a/templates/ktcore/document/view.smarty b/templates/ktcore/document/view.smarty index 2630cde..4385ab3 100644 --- a/templates/ktcore/document/view.smarty +++ b/templates/ktcore/document/view.smarty @@ -1,4 +1,4 @@ -FIXME
diff --git a/templates/ktcore/metadata/conditional/ajax_complex_get_behaviour_list.smarty b/templates/ktcore/metadata/conditional/ajax_complex_get_behaviour_list.smarty index e9b629f..55b60ba 100644 --- a/templates/ktcore/metadata/conditional/ajax_complex_get_behaviour_list.smarty +++ b/templates/ktcore/metadata/conditional/ajax_complex_get_behaviour_list.smarty @@ -1,5 +1,5 @@