composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -1,9 +1,17 @@
<?php
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel
* PHPExcel_Reader_HTML
*
* Copyright (c) 2006 - 2014 PHPExcel
* Copyright (c) 2006 - 2015 PHPExcel
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -21,26 +29,11 @@
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @version ##VERSION##, ##DATE##
*/
/** PHPExcel root directory */
if (!defined('PHPEXCEL_ROOT')) {
/**
* @ignore
*/
define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../');
require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
}
/**
* PHPExcel_Reader_HTML
*
* @category PHPExcel
* @package PHPExcel_Reader
* @copyright Copyright (c) 2006 - 2014 PHPExcel (http://www.codeplex.com/PHPExcel)
*/
class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_Reader_IReader
{
@@ -49,56 +42,75 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @var string
*/
protected $_inputEncoding = 'ANSI';
protected $inputEncoding = 'ANSI';
/**
* Sheet index to read
*
* @var int
*/
protected $_sheetIndex = 0;
protected $sheetIndex = 0;
/**
* Formats
*
* @var array
*/
protected $_formats = array(
'h1' => array('font' => array('bold' => true,
protected $formats = array(
'h1' => array(
'font' => array(
'bold' => true,
'size' => 24,
),
), // Bold, 24pt
'h2' => array('font' => array('bold' => true,
), // Bold, 24pt
'h2' => array(
'font' => array(
'bold' => true,
'size' => 18,
),
), // Bold, 18pt
'h3' => array('font' => array('bold' => true,
), // Bold, 18pt
'h3' => array(
'font' => array(
'bold' => true,
'size' => 13.5,
),
), // Bold, 13.5pt
'h4' => array('font' => array('bold' => true,
), // Bold, 13.5pt
'h4' => array(
'font' => array(
'bold' => true,
'size' => 12,
),
), // Bold, 12pt
'h5' => array('font' => array('bold' => true,
), // Bold, 12pt
'h5' => array(
'font' => array(
'bold' => true,
'size' => 10,
),
), // Bold, 10pt
'h6' => array('font' => array('bold' => true,
), // Bold, 10pt
'h6' => array(
'font' => array(
'bold' => true,
'size' => 7.5,
),
), // Bold, 7.5pt
'a' => array('font' => array('underline' => true,
'color' => array('argb' => PHPExcel_Style_Color::COLOR_BLUE,
), // Bold, 7.5pt
'a' => array(
'font' => array(
'underline' => true,
'color' => array(
'argb' => PHPExcel_Style_Color::COLOR_BLUE,
),
),
), // Blue underlined
'hr' => array('borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(\PHPExcel_Style_Color::COLOR_BLACK,
), // Blue underlined
'hr' => array(
'borders' => array(
'bottom' => array(
'style' => PHPExcel_Style_Border::BORDER_THIN,
'color' => array(
PHPExcel_Style_Color::COLOR_BLACK,
),
),
),
), // Bottom border
), // Bottom border
);
protected $rowspan = array();
@@ -108,7 +120,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function __construct()
{
$this->_readFilter = new PHPExcel_Reader_DefaultReadFilter();
$this->readFilter = new PHPExcel_Reader_DefaultReadFilter();
}
/**
@@ -116,16 +128,16 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*
* @return boolean
*/
protected function _isValidFormat()
protected function isValidFormat()
{
// Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->_fileHandle, 2048);
if ((strpos($data, '<') !== FALSE) &&
// Reading 2048 bytes should be enough to validate that the format is HTML
$data = fread($this->fileHandle, 2048);
if ((strpos($data, '<') !== false) &&
(strlen($data) !== strlen(strip_tags($data)))) {
return TRUE;
return true;
}
return FALSE;
return false;
}
/**
@@ -151,7 +163,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function setInputEncoding($pValue = 'ANSI')
{
$this->_inputEncoding = $pValue;
$this->inputEncoding = $pValue;
return $this;
}
@@ -163,237 +175,242 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function getInputEncoding()
{
return $this->_inputEncoding;
return $this->inputEncoding;
}
// Data Array used for testing only, should write to PHPExcel object on completion of tests
protected $_dataArray = array();
protected $_tableLevel = 0;
protected $_nestedColumn = array('A');
// Data Array used for testing only, should write to PHPExcel object on completion of tests
protected $dataArray = array();
protected $tableLevel = 0;
protected $nestedColumn = array('A');
protected function _setTableStartColumn($column)
protected function setTableStartColumn($column)
{
if ($this->_tableLevel == 0)
if ($this->tableLevel == 0) {
$column = 'A';
++$this->_tableLevel;
$this->_nestedColumn[$this->_tableLevel] = $column;
}
++$this->tableLevel;
$this->nestedColumn[$this->tableLevel] = $column;
return $this->_nestedColumn[$this->_tableLevel];
return $this->nestedColumn[$this->tableLevel];
}
protected function _getTableStartColumn()
protected function getTableStartColumn()
{
return $this->_nestedColumn[$this->_tableLevel];
return $this->nestedColumn[$this->tableLevel];
}
protected function _releaseTableStartColumn()
protected function releaseTableStartColumn()
{
--$this->_tableLevel;
--$this->tableLevel;
return array_pop($this->_nestedColumn);
return array_pop($this->nestedColumn);
}
protected function _flushCell($sheet, $column, $row, &$cellContent)
protected function flushCell($sheet, $column, $row, &$cellContent)
{
if (is_string($cellContent)) {
// Simple String content
// Simple String content
if (trim($cellContent) > '') {
// Only actually write it if there's content in the string
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
// Only actually write it if there's content in the string
// echo 'FLUSH CELL: ' , $column , $row , ' => ' , $cellContent , '<br />';
// Write to worksheet to be done here...
// ... we return the cell so we can mess about with styles more easily
$sheet->setCellValue($column . $row, $cellContent, true);
$this->_dataArray[$row][$column] = $cellContent;
$this->dataArray[$row][$column] = $cellContent;
}
} else {
// We have a Rich Text run
// TODO
$this->_dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
// We have a Rich Text run
// TODO
$this->dataArray[$row][$column] = 'RICH TEXT: ' . $cellContent;
}
$cellContent = (string) '';
}
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
protected function processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null)
{
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$domText = preg_replace('/\s+/u', ' ', trim($child->nodeValue));
if (is_string($cellContent)) {
// simply append the text if the cell content is a plain text string
// simply append the text if the cell content is a plain text string
$cellContent .= $domText;
} else {
// but if we have a rich text run instead, we need to append it correctly
// TODO
// but if we have a rich text run instead, we need to append it correctly
// TODO
}
} elseif ($child instanceof DOMElement) {
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
// echo '<b>DOM ELEMENT: </b>' , strtoupper($child->nodeName) , '<br />';
$attributeArray = array();
foreach ($child->attributes as $attribute) {
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
// echo '<b>ATTRIBUTE: </b>' , $attribute->name , ' => ' , $attribute->value , '<br />';
$attributeArray[$attribute->name] = $attribute->value;
}
switch ($child->nodeName) {
case 'meta' :
case 'meta':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'content':
// TODO
// Extract character set, so we can convert to UTF-8 if required
// TODO
// Extract character set, so we can convert to UTF-8 if required
break;
}
}
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'title' :
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
case 'title':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet->setTitle($cellContent);
$cellContent = '';
break;
case 'span' :
case 'div' :
case 'font' :
case 'i' :
case 'em' :
case 'span':
case 'div':
case 'font':
case 'i':
case 'em':
case 'strong':
case 'b' :
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '')
case 'b':
// echo 'STYLING, SPAN OR DIV<br />';
if ($cellContent > '') {
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '')
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') {
$cellContent .= ' ';
// echo 'END OF STYLING, SPAN OR DIV<br />';
}
// echo 'END OF STYLING, SPAN OR DIV<br />';
break;
case 'hr' :
$this->_flushCell($sheet, $column, $row, $cellContent);
case 'hr':
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
} else {
$cellContent = '----------';
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
case 'br' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
// Add a break after a horizontal rule, simply by allowing the code to dropthru
case 'br':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
} else {
// Otherwise flush our existing content and move the row cursor on
$this->_flushCell($sheet, $column, $row, $cellContent);
// Otherwise flush our existing content and move the row cursor on
$this->flushCell($sheet, $column, $row, $cellContent);
++$row;
}
// echo 'HARD LINE BREAK: ' , '<br />';
// echo 'HARD LINE BREAK: ' , '<br />';
break;
case 'a' :
// echo 'START OF HYPERLINK: ' , '<br />';
case 'a':
// echo 'START OF HYPERLINK: ' , '<br />';
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'href':
// echo 'Link to ' , $attributeValue , '<br />';
// echo 'Link to ' , $attributeValue , '<br />';
$sheet->getCell($column . $row)->getHyperlink()->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF HYPERLINK:' , '<br />';
break;
case 'h1' :
case 'h2' :
case 'h3' :
case 'h4' :
case 'h5' :
case 'h6' :
case 'ol' :
case 'ul' :
case 'p' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
case 'ol':
case 'ul':
case 'p':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
$row++;
}
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent);
// echo 'START OF PARAGRAPH: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF PARAGRAPH:' , '<br />';
$this->flushCell($sheet, $column, $row, $cellContent);
if (isset($this->_formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->_formats[$child->nodeName]);
if (isset($this->formats[$child->nodeName])) {
$sheet->getStyle($column . $row)->applyFromArray($this->formats[$child->nodeName]);
}
$row++;
$column = 'A';
}
break;
case 'li' :
if ($this->_tableLevel > 0) {
// If we're inside a table, replace with a \n
case 'li':
if ($this->tableLevel > 0) {
// If we're inside a table, replace with a \n
$cellContent .= "\n";
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
} else {
if ($cellContent > '') {
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
}
++$row;
// echo 'LIST ENTRY: ' , '<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->_flushCell($sheet, $column, $row, $cellContent);
// echo 'LIST ENTRY: ' , '<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF LIST ENTRY:' , '<br />';
$this->flushCell($sheet, $column, $row, $cellContent);
$column = 'A';
}
break;
case 'table' :
$this->_flushCell($sheet, $column, $row, $cellContent);
$column = $this->_setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
if ($this->_tableLevel > 1)
case 'table':
$this->flushCell($sheet, $column, $row, $cellContent);
$column = $this->setTableStartColumn($column);
// echo 'START OF TABLE LEVEL ' , $this->tableLevel , '<br />';
if ($this->tableLevel > 1) {
--$row;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->_tableLevel , '<br />';
$column = $this->_releaseTableStartColumn();
if ($this->_tableLevel > 1) {
}
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE LEVEL ' , $this->tableLevel , '<br />';
$column = $this->releaseTableStartColumn();
if ($this->tableLevel > 1) {
++$column;
} else {
++$row;
}
break;
case 'thead' :
case 'tbody' :
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
case 'thead':
case 'tbody':
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'tr' :
$column = $this->_getTableStartColumn();
case 'tr':
$column = $this->getTableStartColumn();
$cellContent = '';
// echo 'START OF TABLE ' , $this->_tableLevel , ' ROW<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'START OF TABLE ' , $this->tableLevel , ' ROW<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
++$row;
// echo 'END OF TABLE ' , $this->_tableLevel , ' ROW<br />';
// echo 'END OF TABLE ' , $this->tableLevel , ' ROW<br />';
break;
case 'th' :
case 'td' :
// echo 'START OF TABLE ' , $this->_tableLevel , ' CELL<br />';
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE ' , $this->_tableLevel , ' CELL<br />';
case 'th':
case 'td':
// echo 'START OF TABLE ' , $this->tableLevel , ' CELL<br />';
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
// echo 'END OF TABLE ' , $this->tableLevel , ' CELL<br />';
while (isset($this->rowspan[$column . $row])) {
++$column;
}
$this->_flushCell($sheet, $column, $row, $cellContent);
$this->flushCell($sheet, $column, $row, $cellContent);
// if (isset($attributeArray['style']) && !empty($attributeArray['style'])) {
// $styleAry = $this->getPhpExcelStyleArray($attributeArray['style']);
@@ -433,15 +450,15 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
}
++$column;
break;
case 'body' :
case 'body':
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->tableLevel = 0;
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
break;
default:
$this->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this->processDomElement($child, $sheet, $row, $column, $cellContent);
}
}
}
@@ -458,37 +475,37 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
public function loadIntoExisting($pFilename, PHPExcel $objPHPExcel)
{
// Open file to validate
$this->_openFile($pFilename);
if (!$this->_isValidFormat()) {
fclose($this->_fileHandle);
$this->openFile($pFilename);
if (!$this->isValidFormat()) {
fclose($this->fileHandle);
throw new PHPExcel_Reader_Exception($pFilename . " is an Invalid HTML file.");
}
// Close after validating
fclose($this->_fileHandle);
// Close after validating
fclose($this->fileHandle);
// Create new PHPExcel
while ($objPHPExcel->getSheetCount() <= $this->_sheetIndex) {
while ($objPHPExcel->getSheetCount() <= $this->sheetIndex) {
$objPHPExcel->createSheet();
}
$objPHPExcel->setActiveSheetIndex($this->_sheetIndex);
$objPHPExcel->setActiveSheetIndex($this->sheetIndex);
// Create a new DOM object
// Create a new DOM object
$dom = new domDocument;
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML($this->securityScanFile($pFilename));
if ($loaded === FALSE) {
throw new PHPExcel_Reader_Exception('Failed to load ', $pFilename, ' as a DOM Document');
// Reload the HTML file into the DOM object
$loaded = $dom->loadHTML(mb_convert_encoding($this->securityScanFile($pFilename), 'HTML-ENTITIES', 'UTF-8'));
if ($loaded === false) {
throw new PHPExcel_Reader_Exception('Failed to load ' . $pFilename . ' as a DOM Document');
}
// Discard white space
// Discard white space
$dom->preserveWhiteSpace = false;
$row = 0;
$column = 'A';
$content = '';
$this->_processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
$this->processDomElement($dom, $objPHPExcel->getActiveSheet(), $row, $column, $content);
// Return
// Return
return $objPHPExcel;
}
@@ -499,7 +516,7 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function getSheetIndex()
{
return $this->_sheetIndex;
return $this->sheetIndex;
}
/**
@@ -510,25 +527,23 @@ class PHPExcel_Reader_HTML extends PHPExcel_Reader_Abstract implements PHPExcel_
*/
public function setSheetIndex($pValue = 0)
{
$this->_sheetIndex = $pValue;
$this->sheetIndex = $pValue;
return $this;
}
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
/**
* Scan theXML for use of <!ENTITY to prevent XXE/XEE attacks
*
* @param string $xml
* @throws PHPExcel_Reader_Exception
*/
public function securityScan($xml)
{
$pattern = '/\\0?' . implode('\\0?', str_split('<!ENTITY')) . '\\0?/';
if (preg_match($pattern, $xml)) {
if (preg_match($pattern, $xml)) {
throw new PHPExcel_Reader_Exception('Detected use of ENTITY in XML, spreadsheet file load() aborted to prevent XXE/XEE attacks');
}
return $xml;
}
}