security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -0,0 +1,106 @@
<?php
/**
* Class \LessEngine
*/
abstract class LessEngine implements LessEngineInterface {
/**
* Path to the input .less file.
*
* @var string
*/
protected $input_file_path;
/**
* This will get populated with a list of files that $input_file_path depended
* on through @import statements.
*
* @var string[]
*/
protected $dependencies = array();
/**
* This contains any variables that are to be modified into the output.
*
* Key => value pairs, where the key is the LESS variable name.
*
* @var string[]
*/
protected $variables = array();
/**
* List of directories that are to be used for @import lookups.
*
* @var string[]
*/
protected $import_directories = array();
/**
* Flag if source maps are enabled.
*
* @var bool
*/
protected $source_maps_enabled = FALSE;
/**
* @var string|NULL
*/
protected $source_maps_base_path = NULL;
/**
* @var string|NULL
*/
protected $source_maps_root_path = NULL;
/**
* Basic constructor.
*
* Sets input_file_path property.
*
* @param string $input_file_path
*/
public function __construct($input_file_path) {
$this->input_file_path = $input_file_path;
}
/**
* {@inheritdoc}
*/
public function setImportDirectories(array $directories) {
$this->import_directories = $directories;
}
/**
* {@inheritdoc}
*/
public function setSourceMaps($enabled = FALSE, $base_path = NULL, $root_path = NULL) {
$this->source_maps_enabled = $enabled;
$this->source_maps_base_path = $base_path;
$this->source_maps_root_path = $root_path;
}
/**
* {@inheritdoc}
*/
public function modifyVariables(array $variables) {
$this->variables = $variables;
}
/**
* {@inheritdoc}
*/
public function getDependencies() {
return $this->dependencies;
}
/**
* {@inheritdoc}
*/
abstract public function compile();
}

View File

@@ -0,0 +1,71 @@
<?php
/**
* Class \LessEngineLess_js
*/
class LessEngineLess_js extends LessEngine {
/**
* @var \Lessjs
*/
private $less_js_parser;
/**
* Instantiates new instances of \Lessjs.
*
* @param string $input_file_path
*
* @see \Lessjs
*/
public function __construct($input_file_path) {
parent::__construct($input_file_path);
$this->less_js_parser = Lessjs::create($this->input_file_path);
}
/**
* We override here because getting dependencies from less.js requires another
* full parse. This way we only do that if dependencies are requested.
*
* @return string[]
*
* @see \Lessjs::depends()
*/
public function getDependencies() {
$this->dependencies = $this->less_js_parser->depends();
return parent::getDependencies();
}
/**
* {@inheritdoc}
* This compiles using engine specific function calls.
*/
public function compile() {
$compiled_styles = NULL;
try {
$this->less_js_parser->source_maps($this->source_maps_enabled, $this->source_maps_base_path, $this->source_maps_root_path);
foreach ($this->import_directories as $directory) {
$this->less_js_parser->include_path($directory);
}
foreach ($this->variables as $var_name => $var_value) {
$this->less_js_parser->modify_var(trim($var_name, '@'), trim($var_value, ';'));
}
$compiled_styles = $this->less_js_parser->compile();
}
catch (Exception $e) {
throw $e;
}
return $compiled_styles;
}
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* Class \LessEngineLess_php
*/
class LessEngineLess_php extends LessEngine {
/**
* @var \Less_Parser
*/
private $less_php_parser;
/**
* Instantiates new instances of \Less_Parser.
*
* @param string $input_file_path
*
* @see \Less_Parser
*/
public function __construct($input_file_path) {
parent::__construct($input_file_path);
$this->less_php_parser = new Less_Parser();
}
/**
* {@inheritdoc}
* This compiles using engine specific function calls.
*/
public function compile() {
$compiled_styles = NULL;
try {
if ($this->source_maps_enabled) {
$this->less_php_parser->SetOption('sourceMap', $this->source_maps_enabled);
$this->less_php_parser->SetOption('sourceMapBasepath', $this->source_maps_base_path);
$this->less_php_parser->SetOption('sourceMapRootpath', $this->source_maps_root_path);
}
// Less.js does not allow path aliasing. Set aliases to blank for consistency.
$this->less_php_parser->SetImportDirs(array_fill_keys($this->import_directories, ''));
$this->less_php_parser->parseFile($this->input_file_path);
$this->less_php_parser->ModifyVars($this->variables);
$compiled_styles = $this->less_php_parser->getCss();
$this->dependencies = $this->less_php_parser->AllParsedFiles();
}
catch (Exception $e) {
throw $e;
}
return $compiled_styles;
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* Class \LessEngineLessphp
*/
class LessEngineLessphp extends LessEngine {
/**
* @var \lessc
*/
private $less_php_parser;
/**
* Instantiates new instances of \lessc.
*
* @param string $input_file_path
*
* @see \lessc
*/
public function __construct($input_file_path) {
parent::__construct($input_file_path);
$this->less_php_parser = new lessc();
}
/**
* {@inheritdoc}
* This compiles using engine specific function calls.
*/
public function compile() {
$compiled_styles = NULL;
try {
foreach ($this->import_directories as $directory) {
$this->less_php_parser->addImportDir($directory);
}
$cache = $this->less_php_parser->cachedCompile($this->input_file_path);
$this->dependencies = array_keys($cache['files']);
$compiled_styles = $cache['compiled'];
}
catch (Exception $e) {
throw $e;
}
return $compiled_styles;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/**
* Interface \LessEngineInterface
*/
interface LessEngineInterface {
/**
* Set list of lookup directories for @import statements.
*
* @param string[] $directories
* Flat array of paths relative to DRUPAL_ROOT.
*/
public function setImportDirectories(array $directories);
/**
* Enable
*
* @param bool $enabled
* Set the source maps flag.
* @param string $base_path
* Leading value to be stripped from each source map URL.
* @link http://lesscss.org/usage/#command-line-usage-source-map-basepath
* @param string $root_path
* Value to be prepended to each source map URL.
* @link http://lesscss.org/usage/#command-line-usage-source-map-rootpath
*/
public function setSourceMaps($enabled, $base_path, $root_path);
/**
* Set/override variables.
*
* Variables defined here work in the "modify" method. They are applied after
* parsing but before compilation.
*
* @param string[] $variables
*
* @link http://lesscss.org/usage/#command-line-usage-modify-variable
*/
public function modifyVariables(array $variables);
/**
* Returns list of dependencies.
*
* Returns a list of files that included through @import statements. This list
* is used to determine if parent file needs to be recompiled based on changes
* in dependencies.
*
* @return string[]
* List of paths relative to DRUPAL_ROOT
*/
public function getDependencies();
/**
* This returns the compiled output from the LESS engine.
*
* All output, including source maps, should be contained within the returned
* string.
*
* @return string
* Plain CSS.
*
* @throws Exception
* Rethrows exception from implementation library.
*/
public function compile();
}