Skip to content

Commit

Permalink
Only http url scheme's should be used through curl
Browse files Browse the repository at this point in the history
  • Loading branch information
coreation committed Dec 21, 2015
1 parent a03a077 commit e7ac97f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions app/Tdt/Core/DataControllers/JSONController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ private function getPlainJson($uri)
}

if (!filter_var($uri, FILTER_VALIDATE_URL) === false) {
$data = $this->getRemoteData($uri);
$parts = parse_url($uri);
if ($parts['scheme'] != 'file') {
$data = $this->getRemoteData($uri);
} else {
$data =@ file_get_contents($uri);
}
} else {
$data =@ file_get_contents($uri);
}
Expand Down Expand Up @@ -139,9 +144,9 @@ private function getRemoteData($url)
curl_close($c);

preg_match('/(http(|s)):\/\/(.*?)\/(.*\/|)/si', $status['url'], $link);
$data = preg_replace('/(src|href|action)=(\'|\")((?!(http|https|javascript:|\/\/|\/)).*?)(\'|\")/si', '$1=$2'.$link[0] . '$3$4$5', $data);
$data = preg_replace('/(src|href|action)=(\'|\")((?!(http|https|javascript:|\/\/|\/)).*?)(\'|\")/si', '$1=$2' . $link[0] . '$3$4$5', $data);

$data=preg_replace('/(src|href|action)=(\'|\")((?!(http|https|javascript:|\/\/)).*?)(\'|\")/si', '$1=$2' . $link[1] .'://' . $link[3] . '$3$4$5', $data);
$data = preg_replace('/(src|href|action)=(\'|\")((?!(http|https|javascript:|\/\/)).*?)(\'|\")/si', '$1=$2' . $link[1] . '://' . $link[3] . '$3$4$5', $data);

if ($status['http_code'] == 200) {
return $data;
Expand Down
3 changes: 0 additions & 3 deletions app/Tdt/Core/Formatters/JSONFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ public static function createResponse($dataObj)

public static function getBody($dataObj)
{

// If the data is semantic, return json ld
if ($dataObj->is_semantic) {

$jsonld_formatter = new JSONLDFormatter();

return $jsonld_formatter->getBody($dataObj);
Expand All @@ -42,7 +40,6 @@ public static function getBody($dataObj)
}

if ($dataObj->is_semantic) {

// Check if a configuration is given
$conf = array();
if (!empty($dataObj->semantic->conf)) {
Expand Down

0 comments on commit e7ac97f

Please sign in to comment.