Skip to content

Commit

Permalink
Merge pull request #2471 from codeigniter4/escaper
Browse files Browse the repository at this point in the history
Transition from Zend Escaper to Laminas Escaper
  • Loading branch information
lonnieezell authored Jan 2, 2020
2 parents 0d75ea2 + 91db7c3 commit c879273
Show file tree
Hide file tree
Showing 15 changed files with 70 additions and 72 deletions.
8 changes: 5 additions & 3 deletions admin/framework/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "codeigniter4/framework",
"name": "codeigniter4/codeigniter4",
"type": "project",
"description": "The CodeIgniter framework v4",
"homepage": "https://codeigniter.com",
Expand All @@ -8,9 +8,10 @@
"php": ">=7.2",
"ext-curl": "*",
"ext-intl": "*",
"ext-json": "*",
"kint-php/kint": "^2.1",
"psr/log": "^1.1",
"zendframework/zend-escaper": "^2.5"
"laminas/laminas-escaper": "^2.6"
},
"require-dev": {
"codeigniter4/codeigniter4-standard": "^1.0",
Expand All @@ -26,7 +27,8 @@
"scripts": {
"post-update-cmd": [
"@composer dump-autoload",
"CodeIgniter\\ComposerScripts::postUpdate"
"CodeIgniter\\ComposerScripts::postUpdate",
"bash admin/setup.sh"
]
},
"support": {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"ext-json": "*",
"kint-php/kint": "^2.1",
"psr/log": "^1.1",
"zendframework/zend-escaper": "^2.5"
"laminas/laminas-escaper": "^2.6"
},
"require-dev": {
"codeigniter4/codeigniter4-standard": "^1.0",
Expand Down
2 changes: 1 addition & 1 deletion system/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
use Config\Logger;
use Config\Services;
use Tests\Support\Log\TestLogger;
use Zend\Escaper\Escaper;
use Laminas\Escaper\Escaper;

/**
* Common Functions
Expand Down
14 changes: 7 additions & 7 deletions system/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ protected static function removeDir($dir)
}

/**
* Moves the Zend Escaper files into our base repo so that it's
* Moves the Laminas Escaper files into our base repo so that it's
* available for packaged releases where the users don't user Composer.
*
* @throws \ReflectionException
*/
public static function moveEscaper()
{
if (class_exists('\\Zend\\Escaper\\Escaper') && is_file(static::getClassFilePath('\\Zend\\Escaper\\Escaper')))
if (class_exists('\\Laminas\\Escaper\\Escaper') && is_file(static::getClassFilePath('\\Laminas\\Escaper\\Escaper')))
{
$base = basename(__DIR__) . '/' . static::$basePath . 'ZendEscaper';
$base = basename(__DIR__) . '/' . static::$basePath . 'Escaper';

foreach ([$base, $base . '/Exception'] as $path)
{
Expand All @@ -170,10 +170,10 @@ public static function moveEscaper()
}

$files = [
static::getClassFilePath('\\Zend\\Escaper\\Exception\\ExceptionInterface') => $base . '/Exception/ExceptionInterface.php',
static::getClassFilePath('\\Zend\\Escaper\\Exception\\InvalidArgumentException') => $base . '/Exception/InvalidArgumentException.php',
static::getClassFilePath('\\Zend\\Escaper\\Exception\\RuntimeException') => $base . '/Exception/RuntimeException.php',
static::getClassFilePath('\\Zend\\Escaper\\Escaper') => $base . '/Escaper.php',
static::getClassFilePath('\\Laminas\\Escaper\\Exception\\ExceptionInterface') => $base . '/Exception/ExceptionInterface.php',
static::getClassFilePath('\\Laminas\\Escaper\\Exception\\InvalidArgumentException') => $base . '/Exception/InvalidArgumentException.php',
static::getClassFilePath('\\Laminas\\Escaper\\Exception\\RuntimeException') => $base . '/Exception/RuntimeException.php',
static::getClassFilePath('\\Laminas\\Escaper\\Escaper') => $base . '/Escaper.php',
];

foreach ($files as $source => $dest)
Expand Down
2 changes: 1 addition & 1 deletion system/Config/AutoloadConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function __construct()
'Psr\Log\LoggerTrait' => SYSTEMPATH . 'ThirdParty/PSR/Log/LoggerTrait.php',
'Psr\Log\LogLevel' => SYSTEMPATH . 'ThirdParty/PSR/Log/LogLevel.php',
'Psr\Log\NullLogger' => SYSTEMPATH . 'ThirdParty/PSR/Log/NullLogger.php',
'Zend\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/ZendEscaper/Escaper.php',
'Laminas\Escaper\Escaper' => SYSTEMPATH . 'ThirdParty/Escaper/Escaper.php',
];

if (isset($_SERVER['CI_ENVIRONMENT']) && $_SERVER['CI_ENVIRONMENT'] === 'testing')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php

/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @see https://github.com/laminas/laminas-escaper for the canonical source repository
* @copyright https://github.com/laminas/laminas-escaper/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-escaper/blob/master/LICENSE.md New BSD License
*/

namespace Zend\Escaper;
namespace Laminas\Escaper;

/**
* Context specific methods for use in secure output escaping
Expand Down
13 changes: 13 additions & 0 deletions system/ThirdParty/Escaper/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* @see https://github.com/laminas/laminas-escaper for the canonical source repository
* @copyright https://github.com/laminas/laminas-escaper/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-escaper/blob/master/LICENSE.md New BSD License
*/

namespace Laminas\Escaper\Exception;

interface ExceptionInterface
{
}
17 changes: 17 additions & 0 deletions system/ThirdParty/Escaper/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @see https://github.com/laminas/laminas-escaper for the canonical source repository
* @copyright https://github.com/laminas/laminas-escaper/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-escaper/blob/master/LICENSE.md New BSD License
*/

namespace Laminas\Escaper\Exception;

/**
* Invalid argument exception
*/
class InvalidArgumentException extends \InvalidArgumentException implements
ExceptionInterface
{
}
17 changes: 17 additions & 0 deletions system/ThirdParty/Escaper/Exception/RuntimeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* @see https://github.com/laminas/laminas-escaper for the canonical source repository
* @copyright https://github.com/laminas/laminas-escaper/blob/master/COPYRIGHT.md
* @license https://github.com/laminas/laminas-escaper/blob/master/LICENSE.md New BSD License
*/

namespace Laminas\Escaper\Exception;

/**
* Invalid argument exception
*/
class RuntimeException extends \RuntimeException implements
ExceptionInterface
{
}
14 changes: 0 additions & 14 deletions system/ThirdParty/ZendEscaper/Exception/ExceptionInterface.php

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions system/ThirdParty/ZendEscaper/Exception/RuntimeException.php

This file was deleted.

2 changes: 1 addition & 1 deletion system/View/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public function section(string $name)
/**
*
*
* @throws \Zend\Escaper\Exception\RuntimeException
* @throws \Laminas\Escaper\Exception\RuntimeException
*/
public function endSection()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Autoloader/AutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,6 @@ public function testFindsComposerRoutes()
$this->loader->initialize($config, $moduleConfig);

$namespaces = $this->loader->getNamespace();
$this->assertArrayHasKey('Zend\\Escaper', $namespaces);
$this->assertArrayHasKey('Laminas\\Escaper', $namespaces);
}
}
2 changes: 1 addition & 1 deletion user_guide_src/source/general/common_functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Service Accessors
:rtype: mixed

Escapes data for inclusion in web pages, to help prevent XSS attacks.
This uses the Zend Escaper library to handle the actual filtering of the data.
This uses the Laminas Escaper library to handle the actual filtering of the data.

If $data is a string, then it simply escapes and returns it.
If $data is an array, then it loops over it, escaping each 'value' of the key/value pairs.
Expand Down

0 comments on commit c879273

Please sign in to comment.