Skip to content

Commit

Permalink
[4.0] Convert plugin system redirect to prepared statements (#25538)
Browse files Browse the repository at this point in the history
  • Loading branch information
HLeithner authored and wilsonge committed Jul 23, 2019
1 parent 416627c commit b8a725a
Showing 1 changed file with 19 additions and 27 deletions.
46 changes: 19 additions & 27 deletions plugins/system/redirect/redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
use Joomla\Event\SubscriberInterface;
use Joomla\String\StringHelper;

Expand Down Expand Up @@ -142,32 +143,23 @@ public function handleError(ErrorEvent $event)

$query->select('*')
->from($this->db->quoteName('#__redirect_links'))
->where(
'('
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($url)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($urlRel)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($urlRootRel)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($urlRootRelSlash)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($urlWithoutQuery)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($urlRelWithoutQuery)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurl)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurlRel)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurlRootRel)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurlRootRelSlash)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurlWithoutQuery)
. ' OR '
. $this->db->quoteName('old_url') . ' = ' . $this->db->quote($orgurlRelWithoutQuery)
. ')'
->whereIn(
$this->db->quoteName('old_url'),
[
$url,
$urlRel,
$urlRootRel,
$urlRootRelSlash,
$urlWithoutQuery,
$urlRelWithoutQuery,
$orgurl,
$orgurlRel,
$orgurlRootRel,
$orgurlRootRelSlash,
$orgurlWithoutQuery,
$orgurlRelWithoutQuery,
],
ParameterType::STRING
);

$this->db->setQuery($query);
Expand Down Expand Up @@ -285,7 +277,7 @@ public function handleError(ErrorEvent $event)

try
{
$this->db->updateObject('#__redirect_links', $redirect, 'id');
$this->db->updateObject('#__redirect_links', $redirect, ['id']);
}
catch (Exception $e)
{
Expand Down

0 comments on commit b8a725a

Please sign in to comment.