Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a work around for openbase_dir restrictions. #225

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 7 additions & 4 deletions src/Basset/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Basset\Factory\FactoryManager;
use Assetic\Filter\FilterInterface;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;

class Asset extends Filterable {

Expand Down Expand Up @@ -296,9 +297,11 @@ protected function detectGroupFromContentType()
$this->getLogger()->warning('Attempting to determine asset group using cURL. This may have a considerable effect on application speed.');

$handler = curl_init($this->absolutePath);


$follow_location = Config::get('basset::follow_location', true);

curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, $follow_location);
curl_setopt($handler, CURLOPT_HEADER, true);
curl_setopt($handler, CURLOPT_NOBODY, true);
curl_setopt($handler, CURLOPT_SSL_VERIFYPEER, false);
Expand Down Expand Up @@ -379,7 +382,7 @@ public function isRaw()
*/
public function getContent()
{
return $this->files->getRemote($this->absolutePath);
return file_get_contents($this->absolutePath);
}

/**
Expand Down Expand Up @@ -415,4 +418,4 @@ public function prepareFilters($production = false)
return $filters->filter(function($filter) { return $filter instanceof FilterInterface; });
}

}
}
18 changes: 18 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,24 @@

'build_path' => 'builds',

/*
|--------------------------------------------------------------------------
| Open Base Dir Restrictions
|--------------------------------------------------------------------------
|
| Some hosts run with open base directory restrictions which prevents certain
| PHP functions from working. Basset relies on Curl's CURLOPT_FOLLOWLOCATION
| to follow location headers when assets don't have recognizable extensions.
| This configuration option lets the developer disable the code that implements
| this known restriction.
|
| Note: that disabling this option could cause redirects on remote assets to
| not be loaded correctly.
|
*/

'follow_location' => true,

/*
|--------------------------------------------------------------------------
| Debug
Expand Down