diff --git a/.travis.yml b/.travis.yml index acdf95cc34..7e3e2fe849 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,6 @@ language: php dist: xenial php: - - 5.3 - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 @@ -15,17 +12,12 @@ php: matrix: include: - - php: 5.3 - dist: precise - env: COMPOSER_MEMORY_LIMIT=3G - - php: 5.4 - dist: trusty - - php: 5.5 - dist: trusty + - php: 5.6 + env: COMPOSER_MEMORY_LIMIT=-1 - php: 7.0 - env: COVERAGE=1 + env: COVERAGE=1 COMPOSER_MEMORY_LIMIT=-1 - php: 7.3 - env: DEPENDENCIES="--ignore-platform-reqs" + env: DEPENDENCIES="--ignore-platform-reqs" COMPOSER_MEMORY_LIMIT=-1 exclude: - php: 5.3 - php: 5.4 diff --git a/composer.json b/composer.json index f5f751ec04..62eece1fe9 100644 --- a/composer.json +++ b/composer.json @@ -58,9 +58,9 @@ "fix": "Fixes issues found by PHP-CS" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.6 || ^7.0", "ext-xml": "*", - "zendframework/zend-escaper": "^2.2", + "laminas/laminas-escaper": "^2.6", "phpoffice/common": "^0.2.9" }, "require-dev": { diff --git a/src/PhpWord/Escaper/AbstractEscaper.php b/src/PhpWord/Escaper/AbstractEscaper.php index 1575c069e2..2f05260e7a 100644 --- a/src/PhpWord/Escaper/AbstractEscaper.php +++ b/src/PhpWord/Escaper/AbstractEscaper.php @@ -17,6 +17,7 @@ namespace PhpOffice\PhpWord\Escaper; +use Laminas\Escaper\Escaper; /** * @since 0.13.0 * @@ -43,4 +44,79 @@ public function escape($input) return $input; } + + public function escapeHtml($input) + { + $escaper = new Escaper(); + + if (is_array($input)) { + foreach ($input as &$item) { + $item = $escaper->escapeHtml($item); + } + } else { + $input = $escaper->escapeHtml($input); + } + + return $input; + } + + public function escapeJs($input) + { + $escaper = new Escaper(); + + if (is_array($input)) { + foreach ($input as &$item) { + $item = $escaper->escapeJs($item); + } + } else { + $input = $escaper->escapeJs($input); + } + + return $input; + } + + public function escapeCss($input) + { + $escaper = new Escaper(); + + if (is_array($input)) { + foreach ($input as &$item) { + $item = $escaper->escapeCss($item); + } + } else { + $input = $escaper->escapeCss($input); + } + + return $input; + } + + public function escapeHtmlAttr($input) + { + $escaper = new Escaper(); + + if (is_array($input)) { + foreach ($input as &$item) { + $item = $escaper->escapeHtmlAttr($item); + } + } else { + $input = $escaper->escapeHtmlAttr($input); + } + + return $input; + } + + public function escapeUrl($input) + { + $escaper = new Escaper(); + + if (is_array($input)) { + foreach ($input as &$item) { + $item = $escaper->escapeUrl($item); + } + } else { + $input = $escaper->escapeUrl($input); + } + + return $input; + } } diff --git a/src/PhpWord/Escaper/EscaperInterface.php b/src/PhpWord/Escaper/EscaperInterface.php index deb2cfbc0e..6d86cf6b50 100644 --- a/src/PhpWord/Escaper/EscaperInterface.php +++ b/src/PhpWord/Escaper/EscaperInterface.php @@ -30,4 +30,39 @@ interface EscaperInterface * @return mixed */ public function escape($input); + + /** + * @param mixed $input + * + * @return mixed + */ + public function escapeHtml($input); + + /** + * @param mixed $input + * + * @return mixed + */ + public function escapeJs($input); + + /** + * @param mixed $input + * + * @return mixed + */ + public function escapeCss($input); + + /** + * @param mixed $input + * + * @return mixed + */ + public function escapeHtmlAttr($input); + + /** + * @param mixed $input + * + * @return mixed + */ + public function escapeUrl($input); } diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php index dc5ccfaadc..6e7153bc0b 100644 --- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php +++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php @@ -19,7 +19,7 @@ use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Writer\AbstractWriter; -use Zend\Escaper\Escaper; +use Laminas\Escaper\Escaper; /** * Abstract HTML element writer @@ -50,7 +50,7 @@ abstract class AbstractElement protected $withoutP = false; /** - * @var \Zend\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper + * @var \Laminas\Escaper\Escaper|\PhpOffice\PhpWord\Escaper\AbstractEscaper */ protected $escaper; diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php index 2d86f399b0..cba5848d6d 100644 --- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php +++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php @@ -19,7 +19,7 @@ use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Writer\AbstractWriter; -use Zend\Escaper\Escaper; +use Laminas\Escaper\Escaper; /** * @since 0.11.0 @@ -32,7 +32,7 @@ abstract class AbstractPart private $parentWriter; /** - * @var \Zend\Escaper\Escaper + * @var \Laminas\Escaper\Escaper */ protected $escaper; diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php index 132890e6ec..b54a30f106 100644 --- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php +++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php @@ -123,7 +123,7 @@ protected function writeOpening() protected function writeText($text) { if (Settings::isOutputEscapingEnabled()) { - return $this->escaper->escape($text); + return $this->escaper->escapeHtml($text); } return CommonText::toUnicode($text); // todo: replace with `return $text;` later.