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

Commit

Permalink
Correcting an issue where invalid regular expressions would cause PHP…
Browse files Browse the repository at this point in the history
… warnings.
  • Loading branch information
Nathan Glasl committed Feb 25, 2016
1 parent 7f52067 commit 6b4632d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions code/dataobjects/LinkMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,16 @@ public function getCMSFields() {
public function validate() {

$result = parent::validate();
if($this->ValidateExternal && $this->RedirectLink && $result->valid() && !MisdirectionService::is_external_URL($this->RedirectLink)) {

// Use third party validation to determine an external URL (https://gist.github.com/dperini/729294 and http://mathiasbynens.be/demo/url-regex).
// Determine whether a regular expression mapping is possible to match against.

if(($this->LinkType === 'Regular Expression') && $result->valid() && (!$this->MappedLink || !is_numeric(@preg_match("%{$this->MappedLink}%", null)))) {
$result->error('Invalid regular expression!');
}

// Use third party validation to determine an external URL (https://gist.github.com/dperini/729294 and http://mathiasbynens.be/demo/url-regex).

if($this->ValidateExternal && $this->RedirectLink && $result->valid() && !MisdirectionService::is_external_URL($this->RedirectLink)) {
$result->error('External URL validation failed!');
}

Expand Down

0 comments on commit 6b4632d

Please sign in to comment.