Upgrade to 3.6.4

This commit is contained in:
Bastian Allgeier
2022-04-05 10:18:36 +02:00
parent 905981da5a
commit fee3f5253d
25 changed files with 1643 additions and 476 deletions

View File

@@ -1,7 +1,7 @@
## ##
## Bundle of CA Root Certificates ## Bundle of CA Root Certificates
## ##
## Certificate data from Mozilla as of: Fri Mar 18 12:29:51 2022 GMT ## Certificate data from Mozilla as of: Tue Mar 29 03:12:05 2022 GMT
## ##
## This is a bundle of X.509 certificates of public Certificate Authorities ## This is a bundle of X.509 certificates of public Certificate Authorities
## (CA). These were automatically extracted from Mozilla's root certificates ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -14,7 +14,7 @@
## Just configure this file as the SSLCACertificateFile. ## Just configure this file as the SSLCACertificateFile.
## ##
## Conversion done with mk-ca-bundle.pl version 1.29. ## Conversion done with mk-ca-bundle.pl version 1.29.
## SHA256: 187ef9dc231135324fe78830cf4462f1ecdeab3e6c9d5e38d623391e88dc5d3c ## SHA256: d59c5c83ce7a7635fa95521d8d245677949b86d5574bfcc6f855b6a48f2d5566
## ##

View File

@@ -3,7 +3,7 @@
"description": "The Kirby 3 core", "description": "The Kirby 3 core",
"license": "proprietary", "license": "proprietary",
"type": "kirby-cms", "type": "kirby-cms",
"version": "3.6.3.1", "version": "3.6.4",
"keywords": [ "keywords": [
"kirby", "kirby",
"cms", "cms",
@@ -31,12 +31,12 @@
"claviska/simpleimage": "3.6.5", "claviska/simpleimage": "3.6.5",
"filp/whoops": "2.14.5", "filp/whoops": "2.14.5",
"getkirby/composer-installer": "^1.2.1", "getkirby/composer-installer": "^1.2.1",
"laminas/laminas-escaper": "2.9.0", "laminas/laminas-escaper": "2.10.0",
"michelf/php-smartypants": "1.8.1", "michelf/php-smartypants": "1.8.1",
"phpmailer/phpmailer": "6.5.4", "phpmailer/phpmailer": "6.5.4",
"psr/log": "1.1.4", "psr/log": "1.1.4",
"symfony/polyfill-intl-idn": "1.24.0", "symfony/polyfill-intl-idn": "1.25.0",
"symfony/polyfill-mbstring": "1.24.0" "symfony/polyfill-mbstring": "1.25.0"
}, },
"replace": { "replace": {
"symfony/polyfill-php72": "*" "symfony/polyfill-php72": "*"

36
kirby/composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a83b6521ea01c32fbdce60852c237a74", "content-hash": "c466eb7751b8b96b729b80a221d1641e",
"packages": [ "packages": [
{ {
"name": "claviska/simpleimage", "name": "claviska/simpleimage",
@@ -175,33 +175,33 @@
}, },
{ {
"name": "laminas/laminas-escaper", "name": "laminas/laminas-escaper",
"version": "2.9.0", "version": "2.10.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-escaper.git", "url": "https://github.com/laminas/laminas-escaper.git",
"reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f" "reference": "58af67282db37d24e584a837a94ee55b9c7552be"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/891ad70986729e20ed2e86355fcf93c9dc238a5f", "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/58af67282db37d24e584a837a94ee55b9c7552be",
"reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f", "reference": "58af67282db37d24e584a837a94ee55b9c7552be",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0" "ext-ctype": "*",
"ext-mbstring": "*",
"php": "^7.4 || ~8.0.0 || ~8.1.0"
}, },
"conflict": { "conflict": {
"zendframework/zend-escaper": "*" "zendframework/zend-escaper": "*"
}, },
"require-dev": { "require-dev": {
"infection/infection": "^0.26.6",
"laminas/laminas-coding-standard": "~2.3.0", "laminas/laminas-coding-standard": "~2.3.0",
"phpunit/phpunit": "^9.3", "maglnet/composer-require-checker": "^3.8.0",
"psalm/plugin-phpunit": "^0.12.2", "phpunit/phpunit": "^9.5.18",
"vimeo/psalm": "^3.16" "psalm/plugin-phpunit": "^0.16.1",
}, "vimeo/psalm": "^4.22.0"
"suggest": {
"ext-iconv": "*",
"ext-mbstring": "*"
}, },
"type": "library", "type": "library",
"autoload": { "autoload": {
@@ -233,7 +233,7 @@
"type": "community_bridge" "type": "community_bridge"
} }
], ],
"time": "2021-09-02T17:10:53+00:00" "time": "2022-03-08T20:15:36+00:00"
}, },
{ {
"name": "league/color-extractor", "name": "league/color-extractor",
@@ -477,7 +477,7 @@
}, },
{ {
"name": "symfony/polyfill-intl-idn", "name": "symfony/polyfill-intl-idn",
"version": "v1.24.0", "version": "v1.25.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git", "url": "https://github.com/symfony/polyfill-intl-idn.git",
@@ -544,7 +544,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.25.0"
}, },
"funding": [ "funding": [
{ {
@@ -648,7 +648,7 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.24.0", "version": "v1.25.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
@@ -711,7 +711,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0"
}, },
"funding": [ "funding": [
{ {

View File

@@ -5,6 +5,7 @@ fields:
images: images:
label: field.blocks.gallery.images.label label: field.blocks.gallery.images.label
type: files type: files
query: model.images
multiple: true multiple: true
layout: cards layout: cards
size: tiny size: tiny

View File

@@ -13,6 +13,7 @@ fields:
image: image:
label: field.blocks.image.name label: field.blocks.image.name
type: files type: files
query: model.images
multiple: false multiple: false
image: image:
back: black back: black

View File

@@ -168,7 +168,7 @@ return [
* @return \Kirby\Cms\Collection|bool * @return \Kirby\Cms\Collection|bool
*/ */
'search' => function (App $kirby, Collection $collection, string $query = null, $params = []) { 'search' => function (App $kirby, Collection $collection, string $query = null, $params = []) {
if (empty(trim($query)) === true) { if (empty(trim($query ?? '')) === true) {
return $collection->limit(0); return $collection->limit(0);
} }

View File

@@ -69,14 +69,13 @@ return [
return $value; return $value;
} }
$value = trim($value);
$converter = $this->converters()[$this->converter()]; $converter = $this->converters()[$this->converter()];
if (is_array($value) === true) { if (is_array($value) === true) {
return array_map($converter, $value); return array_map($converter, $value);
} }
return call_user_func($converter, $value); return call_user_func($converter, trim($value ?? ''));
}, },
'converters' => function (): array { 'converters' => function (): array {
return [ return [

View File

@@ -12,7 +12,8 @@ return [
'form' => function () { 'form' => function () {
$fields = $this->fields; $fields = $this->fields;
$disabled = $this->model->permissions()->update() === false; $disabled = $this->model->permissions()->update() === false;
$content = $this->model->content()->toArray(); $lang = $this->model->kirby()->languageCode();
$content = $this->model->content($lang)->toArray();
if ($disabled === true) { if ($disabled === true) {
foreach ($fields as $key => $props) { foreach ($fields as $key => $props) {

View File

@@ -6,9 +6,16 @@ return [
'props' => [ 'props' => [
/** /**
* The headline for the section. This can be a simple string or a template with additional info from the parent page. * The headline for the section. This can be a simple string or a template with additional info from the parent page.
* @todo deprecate in 3.7
*/ */
'headline' => function ($headline = null) { 'headline' => function ($headline = null) {
return I18n::translate($headline, $headline); return I18n::translate($headline, $headline);
},
/**
* label is the new official replacement for headline
*/
'label' => function ($label = null) {
return I18n::translate($label, $label);
} }
], ],
'computed' => [ 'computed' => [
@@ -17,6 +24,10 @@ return [
return $this->model()->toString($this->headline); return $this->model()->toString($this->headline);
} }
if ($this->label) {
return $this->model()->toString($this->label);
}
return ucfirst($this->name); return ucfirst($this->name);
} }
] ]

View File

@@ -396,7 +396,7 @@
"next": "Næste", "next": "Næste",
"no": "nej", "no": "nej",
"off": "Sluk", "off": "Sluk",
"on": "Tænd", "on": "Aktiveret",
"open": "Åben", "open": "Åben",
"open.newWindow": "Åben i et nyt vindue", "open.newWindow": "Åben i et nyt vindue",
"options": "Indstillinger", "options": "Indstillinger",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -203,12 +203,14 @@ class Blueprint
return $props; return $props;
} }
try { foreach (A::wrap($extends) as $extend) {
$mixin = static::find($extends); try {
$mixin = static::extend($mixin); $mixin = static::find($extend);
$props = A::merge($mixin, $props, A::MERGE_REPLACE); $mixin = static::extend($mixin);
} catch (Exception $e) { $props = A::merge($mixin, $props, A::MERGE_REPLACE);
// keep the props unextended if the snippet wasn't found } catch (Exception $e) {
// keep the props unextended if the snippet wasn't found
}
} }
// remove the extends flag // remove the extends flag

View File

@@ -54,7 +54,7 @@ class Fieldset extends Item
$this->editable = $params['editable'] ?? true; $this->editable = $params['editable'] ?? true;
$this->icon = $params['icon'] ?? null; $this->icon = $params['icon'] ?? null;
$this->model = $this->parent; $this->model = $this->parent;
$this->name = $this->createName($params['name'] ?? Str::ucfirst($this->type)); $this->name = $this->createName($params['title'] ?? $params['name'] ?? Str::ucfirst($this->type));
$this->label = $this->createLabel($params['label'] ?? null); $this->label = $this->createLabel($params['label'] ?? null);
$this->preview = $params['preview'] ?? null; $this->preview = $params['preview'] ?? null;
$this->tabs = $this->createTabs($params); $this->tabs = $this->createTabs($params);

View File

@@ -347,6 +347,7 @@ abstract class ModelWithContent extends Model
$result = Str::query($query, [ $result = Str::query($query, [
'kirby' => $this->kirby(), 'kirby' => $this->kirby(),
'site' => is_a($this, 'Kirby\Cms\Site') ? $this : $this->site(), 'site' => is_a($this, 'Kirby\Cms\Site') ? $this : $this->site(),
'model' => $this,
static::CLASS_ALIAS => $this static::CLASS_ALIAS => $this
]); ]);
} catch (Throwable $e) { } catch (Throwable $e) {

View File

@@ -25,7 +25,7 @@ class PageBlueprint extends Blueprint
// normalize all available page options // normalize all available page options
$this->props['options'] = $this->normalizeOptions( $this->props['options'] = $this->normalizeOptions(
$props['options'] ?? true, $this->props['options'] ?? true,
// defaults // defaults
[ [
'changeSlug' => null, 'changeSlug' => null,
@@ -50,10 +50,10 @@ class PageBlueprint extends Blueprint
); );
// normalize the ordering number // normalize the ordering number
$this->props['num'] = $this->normalizeNum($props['num'] ?? 'default'); $this->props['num'] = $this->normalizeNum($this->props['num'] ?? 'default');
// normalize the available status array // normalize the available status array
$this->props['status'] = $this->normalizeStatus($props['status'] ?? null); $this->props['status'] = $this->normalizeStatus($this->props['status'] ?? null);
} }
/** /**

View File

@@ -26,7 +26,7 @@ class SiteBlueprint extends Blueprint
// normalize all available page options // normalize all available page options
$this->props['options'] = $this->normalizeOptions( $this->props['options'] = $this->normalizeOptions(
$props['options'] ?? true, $this->props['options'] ?? true,
// defaults // defaults
[ [
'changeTitle' => null, 'changeTitle' => null,

View File

@@ -445,7 +445,7 @@ class System
} }
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
$response = Remote::get('https://licenses.getkirby.com/register', [ $response = Remote::get('https://hub.getkirby.com/register', [
'data' => [ 'data' => [
'license' => $license, 'license' => $license,
'email' => Str::lower(trim($email)), 'email' => Str::lower(trim($email)),

View File

@@ -30,7 +30,7 @@ class UserBlueprint extends Blueprint
// normalize all available page options // normalize all available page options
$this->props['options'] = $this->normalizeOptions( $this->props['options'] = $this->normalizeOptions(
$props['options'] ?? true, $this->props['options'] ?? true,
// defaults // defaults
[ [
'create' => null, 'create' => null,

View File

@@ -500,11 +500,7 @@ class Html extends Xml
($attr['allowfullscreen'] ?? true) === true ($attr['allowfullscreen'] ?? true) === true
) { ) {
$attr['allow'] = 'fullscreen'; $attr['allow'] = 'fullscreen';
} $attr['allowfullscreen'] = true;
// remove deprecated attribute
if (isset($attr['allowfullscreen']) === true) {
unset($attr['allowfullscreen']);
} }
return $attr; return $attr;

View File

@@ -178,36 +178,36 @@
}, },
{ {
"name": "laminas/laminas-escaper", "name": "laminas/laminas-escaper",
"version": "2.9.0", "version": "2.10.0",
"version_normalized": "2.9.0.0", "version_normalized": "2.10.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laminas/laminas-escaper.git", "url": "https://github.com/laminas/laminas-escaper.git",
"reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f" "reference": "58af67282db37d24e584a837a94ee55b9c7552be"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/891ad70986729e20ed2e86355fcf93c9dc238a5f", "url": "https://api.github.com/repos/laminas/laminas-escaper/zipball/58af67282db37d24e584a837a94ee55b9c7552be",
"reference": "891ad70986729e20ed2e86355fcf93c9dc238a5f", "reference": "58af67282db37d24e584a837a94ee55b9c7552be",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0" "ext-ctype": "*",
"ext-mbstring": "*",
"php": "^7.4 || ~8.0.0 || ~8.1.0"
}, },
"conflict": { "conflict": {
"zendframework/zend-escaper": "*" "zendframework/zend-escaper": "*"
}, },
"require-dev": { "require-dev": {
"infection/infection": "^0.26.6",
"laminas/laminas-coding-standard": "~2.3.0", "laminas/laminas-coding-standard": "~2.3.0",
"phpunit/phpunit": "^9.3", "maglnet/composer-require-checker": "^3.8.0",
"psalm/plugin-phpunit": "^0.12.2", "phpunit/phpunit": "^9.5.18",
"vimeo/psalm": "^3.16" "psalm/plugin-phpunit": "^0.16.1",
"vimeo/psalm": "^4.22.0"
}, },
"suggest": { "time": "2022-03-08T20:15:36+00:00",
"ext-iconv": "*",
"ext-mbstring": "*"
},
"time": "2021-09-02T17:10:53+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@@ -495,8 +495,8 @@
}, },
{ {
"name": "symfony/polyfill-intl-idn", "name": "symfony/polyfill-intl-idn",
"version": "v1.24.0", "version": "v1.25.0",
"version_normalized": "1.24.0.0", "version_normalized": "1.25.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git", "url": "https://github.com/symfony/polyfill-intl-idn.git",
@@ -529,12 +529,12 @@
}, },
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Intl\\Idn\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Idn\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@@ -565,7 +565,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.25.0"
}, },
"funding": [ "funding": [
{ {
@@ -672,8 +672,8 @@
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
"version": "v1.24.0", "version": "v1.25.0",
"version_normalized": "1.24.0.0", "version_normalized": "1.25.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git", "url": "https://github.com/symfony/polyfill-mbstring.git",
@@ -707,12 +707,12 @@
}, },
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"files": [ "files": [
"bootstrap.php" "bootstrap.php"
] ],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
"license": [ "license": [
@@ -738,7 +738,7 @@
"shim" "shim"
], ],
"support": { "support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0"
}, },
"funding": [ "funding": [
{ {

View File

@@ -1,7 +1,7 @@
<?php return array( <?php return array(
'root' => array( 'root' => array(
'pretty_version' => '3.6.3.1', 'pretty_version' => '3.6.4',
'version' => '3.6.3.1', 'version' => '3.6.4.0',
'type' => 'kirby-cms', 'type' => 'kirby-cms',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@@ -29,8 +29,8 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'getkirby/cms' => array( 'getkirby/cms' => array(
'pretty_version' => '3.6.3.1', 'pretty_version' => '3.6.4',
'version' => '3.6.3.1', 'version' => '3.6.4.0',
'type' => 'kirby-cms', 'type' => 'kirby-cms',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@@ -47,12 +47,12 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'laminas/laminas-escaper' => array( 'laminas/laminas-escaper' => array(
'pretty_version' => '2.9.0', 'pretty_version' => '2.10.0',
'version' => '2.9.0.0', 'version' => '2.10.0.0',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../laminas/laminas-escaper', 'install_path' => __DIR__ . '/../laminas/laminas-escaper',
'aliases' => array(), 'aliases' => array(),
'reference' => '891ad70986729e20ed2e86355fcf93c9dc238a5f', 'reference' => '58af67282db37d24e584a837a94ee55b9c7552be',
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'league/color-extractor' => array( 'league/color-extractor' => array(
@@ -98,8 +98,8 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/polyfill-intl-idn' => array( 'symfony/polyfill-intl-idn' => array(
'pretty_version' => 'v1.24.0', 'pretty_version' => 'v1.25.0',
'version' => '1.24.0.0', 'version' => '1.25.0.0',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-intl-idn', 'install_path' => __DIR__ . '/../symfony/polyfill-intl-idn',
'aliases' => array(), 'aliases' => array(),
@@ -116,8 +116,8 @@
'dev_requirement' => false, 'dev_requirement' => false,
), ),
'symfony/polyfill-mbstring' => array( 'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.24.0', 'pretty_version' => 'v1.25.0',
'version' => '1.24.0.0', 'version' => '1.25.0.0',
'type' => 'library', 'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
'aliases' => array(), 'aliases' => array(),

View File

@@ -16,22 +16,30 @@
"forum": "https://discourse.laminas.dev" "forum": "https://discourse.laminas.dev"
}, },
"config": { "config": {
"sort-packages": true "sort-packages": true,
"platform": {
"php": "7.4.99"
},
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"composer/package-versions-deprecated": true,
"infection/extension-installer": true
}
}, },
"extra": { "extra": {
}, },
"require": { "require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0" "php": "^7.4 || ~8.0.0 || ~8.1.0",
}, "ext-ctype": "*",
"suggest": {
"ext-iconv": "*",
"ext-mbstring": "*" "ext-mbstring": "*"
}, },
"require-dev": { "require-dev": {
"infection/infection": "^0.26.6",
"laminas/laminas-coding-standard": "~2.3.0", "laminas/laminas-coding-standard": "~2.3.0",
"phpunit/phpunit": "^9.3", "maglnet/composer-require-checker": "^3.8.0",
"psalm/plugin-phpunit": "^0.12.2", "phpunit/phpunit": "^9.5.18",
"vimeo/psalm": "^3.16" "psalm/plugin-phpunit": "^0.16.1",
"vimeo/psalm": "^4.22.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

File diff suppressed because it is too large Load Diff

View File

@@ -6,10 +6,8 @@ namespace Laminas\Escaper;
use function bin2hex; use function bin2hex;
use function ctype_digit; use function ctype_digit;
use function function_exists;
use function hexdec; use function hexdec;
use function htmlspecialchars; use function htmlspecialchars;
use function iconv;
use function in_array; use function in_array;
use function mb_convert_encoding; use function mb_convert_encoding;
use function ord; use function ord;
@@ -38,7 +36,7 @@ class Escaper
* entities that XML supports. Using HTML entities would result in this error: * entities that XML supports. Using HTML entities would result in this error:
* XML Parsing Error: undefined entity * XML Parsing Error: undefined entity
* *
* @var array * @var array<int, string>
*/ */
protected static $htmlNamedEntityMap = [ protected static $htmlNamedEntityMap = [
34 => 'quot', // quotation mark 34 => 'quot', // quotation mark
@@ -67,6 +65,7 @@ class Escaper
* Static Matcher which escapes characters for HTML Attribute contexts * Static Matcher which escapes characters for HTML Attribute contexts
* *
* @var callable * @var callable
* @psalm-var callable(array<array-key, string>):string
*/ */
protected $htmlAttrMatcher; protected $htmlAttrMatcher;
@@ -74,6 +73,7 @@ class Escaper
* Static Matcher which escapes characters for Javascript contexts * Static Matcher which escapes characters for Javascript contexts
* *
* @var callable * @var callable
* @psalm-var callable(array<array-key, string>):string
*/ */
protected $jsMatcher; protected $jsMatcher;
@@ -81,6 +81,7 @@ class Escaper
* Static Matcher which escapes characters for CSS Attribute contexts * Static Matcher which escapes characters for CSS Attribute contexts
* *
* @var callable * @var callable
* @psalm-var callable(array<array-key, string>):string
*/ */
protected $cssMatcher; protected $cssMatcher;
@@ -255,7 +256,7 @@ class Escaper
* Callback function for preg_replace_callback that applies HTML Attribute * Callback function for preg_replace_callback that applies HTML Attribute
* escaping to all matches. * escaping to all matches.
* *
* @param array $matches * @param array<array-key, string> $matches
* @return string * @return string
*/ */
protected function htmlAttrMatcher($matches) protected function htmlAttrMatcher($matches)
@@ -302,7 +303,7 @@ class Escaper
* Callback function for preg_replace_callback that applies Javascript * Callback function for preg_replace_callback that applies Javascript
* escaping to all matches. * escaping to all matches.
* *
* @param array $matches * @param array<array-key, string> $matches
* @return string * @return string
*/ */
protected function jsMatcher($matches) protected function jsMatcher($matches)
@@ -325,7 +326,7 @@ class Escaper
* Callback function for preg_replace_callback that applies CSS * Callback function for preg_replace_callback that applies CSS
* escaping to all matches. * escaping to all matches.
* *
* @param array $matches * @param array<array-key, string> $matches
* @return string * @return string
*/ */
protected function cssMatcher($matches) protected function cssMatcher($matches)
@@ -391,32 +392,21 @@ class Escaper
} }
/** /**
* Encoding conversion helper which wraps iconv and mbstring where they exist or throws * Encoding conversion helper which wraps mb_convert_encoding
* and exception where neither is available.
* *
* @param string $string * @param string $string
* @param string $to * @param string $to
* @param array|string $from * @param array|string $from
* @throws Exception\RuntimeException
* @return string * @return string
*/ */
protected function convertEncoding($string, $to, $from) protected function convertEncoding($string, $to, $from)
{ {
if (function_exists('iconv')) { $result = mb_convert_encoding($string, $to, $from);
$result = iconv($from, $to, $string);
} elseif (function_exists('mb_convert_encoding')) {
$result = mb_convert_encoding($string, $to, $from);
} else {
throw new Exception\RuntimeException(
static::class
. ' requires either the iconv or mbstring extension to be installed'
. ' when escaping for non UTF-8 strings.'
);
}
if ($result === false) { if ($result === false) {
return ''; // return non-fatal blank string on encoding errors from users return ''; // return non-fatal blank string on encoding errors from users
} }
return $result; return $result;
} }
} }