Skip to content
This repository has been archived by the owner on Jan 10, 2021. It is now read-only.

Commit

Permalink
Correcting an escaping issue when attempting to match against a regul…
Browse files Browse the repository at this point in the history
…ar expression.
  • Loading branch information
Nathan Glasl committed Mar 18, 2016
1 parent a12cffb commit dfc1942
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/services/MisdirectionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ public function getMapping($URL, $host = null) {
if(is_null($host) && ($controller = Controller::curr())) {
$host = $controller->getRequest()->getHeader('Host');
}
$matches = $matches->where("(HostnameRestriction IS NULL) OR (HostnameRestriction = '" . Convert::raw2sql($host) . "')");
$temporary = $host;
$host = Convert::raw2sql($host);
$matches = $matches->where("(HostnameRestriction IS NULL) OR (HostnameRestriction = '{$host}')");
$regex = clone $matches;

// Determine the simple matching from the database.

$base = Convert::raw2sql($parts[0]);
$matches = $matches->where("(LinkType = 'Simple') AND (((IncludesHostname = 0) AND ((MappedLink = '{$base}') OR (MappedLink LIKE '{$base}?%'))) OR ((IncludesHostname = 1) AND ((MappedLink = '{$host}/{$base}') OR (MappedLink LIKE '{$host}/{$base}?%'))))");
$host = $temporary;
$base = $parts[0];

// Determine the remaining regular expression matching, as this is inconsistent from the database.
Expand Down

0 comments on commit dfc1942

Please sign in to comment.