Skip to content

Commit

Permalink
put the cleanup back
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Jun 19, 2019
1 parent 83165b0 commit a6409db
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions libraries/src/Table/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;

/**
* Content table
Expand Down Expand Up @@ -271,6 +272,36 @@ public function check()
$this->modified = $this->_db->getNullDate();
}

// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->metakey))
{
// Only process if not empty

// Array of characters to remove
$bad_characters = array("\n", "\r", "\"", '<', '>');

// Remove bad characters
$after_clean = StringHelper::str_ireplace($bad_characters, '', $this->metakey);

// Create array using commas as delimiter
$keys = explode(',', $after_clean);

$clean_keys = array();

foreach ($keys as $key)
{
if (trim($key))
{
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}

// Put array back together delimited by ", "
$this->metakey = implode(', ', $clean_keys);
}

return true;
}

Expand Down
31 changes: 31 additions & 0 deletions libraries/src/Table/CoreContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
use Joomla\Utilities\ArrayHelper;

/**
Expand Down Expand Up @@ -144,6 +145,36 @@ public function check()
$this->core_publish_down = $temp;
}

// Clean up keywords -- eliminate extra spaces between phrases
// and cr (\r) and lf (\n) characters from string
if (!empty($this->core_metakey))
{
// Only process if not empty

// Array of characters to remove
$bad_characters = array("\n", "\r", "\"", '<', '>');

// Remove bad characters
$after_clean = StringHelper::str_ireplace($bad_characters, '', $this->core_metakey);

// Create array using commas as delimiter
$keys = explode(',', $after_clean);

$clean_keys = array();

foreach ($keys as $key)
{
if (trim($key))
{
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}

// Put array back together delimited by ", "
$this->core_metakey = implode(', ', $clean_keys);
}

return true;
}

Expand Down

0 comments on commit a6409db

Please sign in to comment.