Skip to content

Update composer.json #1916

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

Closed
wants to merge 19 commits into from
Closed
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
16 changes: 4 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ language: php
dist: xenial

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
76 changes: 76 additions & 0 deletions src/PhpWord/Escaper/AbstractEscaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace PhpOffice\PhpWord\Escaper;

use Laminas\Escaper\Escaper;
/**
* @since 0.13.0
*
Expand All @@ -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;
}
}
35 changes: 35 additions & 0 deletions src/PhpWord/Escaper/EscaperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/PhpWord/Writer/HTML/Element/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Writer/HTML/Part/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,7 +32,7 @@ abstract class AbstractPart
private $parentWriter;

/**
* @var \Zend\Escaper\Escaper
* @var \Laminas\Escaper\Escaper
*/
protected $escaper;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Writer/RTF/Element/AbstractElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down