Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 47 additions & 9 deletions components/com_contact/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,28 @@ public function getCategoryId($segment, $query)
$category = $this->getCategories(['access' => false])->get($query['id']);

if ($category) {
foreach ($category->getChildren() as $child) {
if ($this->noIDs) {
if ($this->noIDs) {
foreach ($category->getChildren() as $child) {
if ($child->alias == $segment) {
return $child->id;
}
} else {
}

// We haven't found a matching category, but maybe we turned off IDs?
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
$this->app->getRouter()->setTainted();

return $child->id;
}
}
} else {
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
if ($child->id . '-' . $child->alias != $segment) {
$this->app->getRouter()->setTainted();
}

return $child->id;
}
}
Expand Down Expand Up @@ -241,20 +256,43 @@ public function getContactId($segment, $query)
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('id'))
->from($this->db->quoteName('#__contact_details'))
->where($this->db->quoteName('alias') . ' = :alias')
->bind(':alias', $segment);
->where($this->db->quoteName('alias') . ' = :segment')
->bind(':segment', $segment);

if (isset($query['id']) && $query['id']) {
$dbquery->where($this->db->quoteName('catid') . ' = :catid')
->bind(':catid', $query['id'], ParameterType::INTEGER);
$dbquery->where($this->db->quoteName('catid') . ' = :id')
->bind(':id', $query['id'], ParameterType::INTEGER);
}

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
$id = (int) $this->db->loadResult();

// Do we have a URL with ID?
if ($id) {
return $id;
}

$this->app->getRouter()->setTainted();
}

$id = (int) $segment;

if ($id) {
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('alias'))
->from($this->db->quoteName('#__contact_details'))
->where($this->db->quoteName('id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$this->db->setQuery($dbquery);
$alias = $this->db->loadResult();

if ($alias && $id . '-' . $alias != $segment) {
$this->app->getRouter()->setTainted();
}
}

return (int) $segment;
return $id;
}

/**
Expand Down
48 changes: 43 additions & 5 deletions components/com_content/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,28 @@ public function getCategoryId($segment, $query)
$category = $this->getCategories(['access' => false])->get($query['id']);

if ($category) {
foreach ($category->getChildren() as $child) {
if ($this->noIDs) {
if ($this->noIDs) {
foreach ($category->getChildren() as $child) {
if ($child->alias == $segment) {
return $child->id;
}
} else {
}

// We haven't found a matching category, but maybe we turned off IDs?
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
$this->app->getRouter()->setTainted();

return $child->id;
}
}
} else {
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
if ($child->id . '-' . $child->alias != $segment) {
$this->app->getRouter()->setTainted();
}

return $child->id;
}
}
Expand Down Expand Up @@ -252,10 +267,33 @@ public function getArticleId($segment, $query)

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
$id = (int) $this->db->loadResult();

// Do we have a URL with ID?
if ($id) {
return $id;
}

$this->app->getRouter()->setTainted();
}

$id = (int) $segment;

if ($id) {
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('alias'))
->from($this->db->quoteName('#__content'))
->where($this->db->quoteName('id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$this->db->setQuery($dbquery);
$alias = $this->db->loadResult();

if ($alias && $id . '-' . $alias != $segment) {
$this->app->getRouter()->setTainted();
}
}

return (int) $segment;
return $id;
}

/**
Expand Down
50 changes: 44 additions & 6 deletions components/com_newsfeeds/src/Service/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,28 @@ public function getCategoryId($segment, $query)
$category = $this->getCategories(['access' => false])->get($query['id']);

if ($category) {
foreach ($category->getChildren() as $child) {
if ($this->noIDs) {
if ($child->alias === $segment) {
if ($this->noIDs) {
foreach ($category->getChildren() as $child) {
if ($child->alias == $segment) {
return $child->id;
}
} else {
}

// We haven't found a matching category, but maybe we turned off IDs?
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
$this->app->getRouter()->setTainted();

return $child->id;
}
}
} else {
foreach ($category->getChildren() as $child) {
if ($child->id == (int) $segment) {
if ($child->id . '-' . $child->alias != $segment) {
$this->app->getRouter()->setTainted();
}

return $child->id;
}
}
Expand Down Expand Up @@ -232,10 +247,33 @@ public function getNewsfeedId($segment, $query)

$this->db->setQuery($dbquery);

return (int) $this->db->loadResult();
$id = (int) $this->db->loadResult();

// Do we have a URL with ID?
if ($id) {
return $id;
}

$this->app->getRouter()->setTainted();
}

$id = (int) $segment;

if ($id) {
$dbquery = $this->db->getQuery(true);
$dbquery->select($this->db->quoteName('alias'))
->from($this->db->quoteName('#__newsfeeds'))
->where($this->db->quoteName('id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$this->db->setQuery($dbquery);
$alias = $this->db->loadResult();

if ($alias && $id . '-' . $alias != $segment) {
$this->app->getRouter()->setTainted();
}
}

return (int) $segment;
return $id;
}

/**
Expand Down