composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\Component\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextInterface;
|
||||
use Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface;
|
||||
use Drupal\Component\Plugin\Exception\ContextException;
|
||||
use Drupal\Component\Plugin\Context\Context;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
|
@ -67,7 +68,12 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
|
|||
*/
|
||||
public function getContextDefinitions() {
|
||||
$definition = $this->getPluginDefinition();
|
||||
return !empty($definition['context']) ? $definition['context'] : [];
|
||||
if ($definition instanceof ContextAwarePluginDefinitionInterface) {
|
||||
return $definition->getContextDefinitions();
|
||||
}
|
||||
else {
|
||||
return !empty($definition['context']) ? $definition['context'] : [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,10 +81,15 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
|
|||
*/
|
||||
public function getContextDefinition($name) {
|
||||
$definition = $this->getPluginDefinition();
|
||||
if (empty($definition['context'][$name])) {
|
||||
throw new ContextException(sprintf("The %s context is not a valid context.", $name));
|
||||
if ($definition instanceof ContextAwarePluginDefinitionInterface) {
|
||||
if ($definition->hasContextDefinition($name)) {
|
||||
return $definition->getContextDefinition($name);
|
||||
}
|
||||
}
|
||||
return $definition['context'][$name];
|
||||
elseif (!empty($definition['context'][$name])) {
|
||||
return $definition['context'][$name];
|
||||
}
|
||||
throw new ContextException(sprintf("The %s context is not a valid context.", $name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -107,6 +107,29 @@ class PhpTransliteration implements TransliterationInterface {
|
|||
public function transliterate($string, $langcode = 'en', $unknown_character = '?', $max_length = NULL) {
|
||||
$result = '';
|
||||
$length = 0;
|
||||
$hash = FALSE;
|
||||
|
||||
// Replace question marks with a unique hash if necessary. This because
|
||||
// mb_convert_encoding() replaces all invalid characters with a question
|
||||
// mark.
|
||||
if ($unknown_character != '?' && strpos($string, '?') !== FALSE) {
|
||||
$hash = hash('sha256', $string);
|
||||
$string = str_replace('?', $hash, $string);
|
||||
}
|
||||
|
||||
// Ensure the string is valid UTF8 for preg_split(). Unknown characters will
|
||||
// be replaced by a question mark.
|
||||
$string = mb_convert_encoding($string, 'UTF-8', 'UTF-8');
|
||||
|
||||
// Use the provided unknown character instead of a question mark.
|
||||
if ($unknown_character != '?') {
|
||||
$string = str_replace('?', $unknown_character, $string);
|
||||
// Restore original question marks if necessary.
|
||||
if ($hash !== FALSE) {
|
||||
$string = str_replace($hash, '?', $string);
|
||||
}
|
||||
}
|
||||
|
||||
// Split into Unicode characters and transliterate each one.
|
||||
foreach (preg_split('//u', $string, 0, PREG_SPLIT_NO_EMPTY) as $character) {
|
||||
$code = self::ordUTF8($character);
|
||||
|
|
67
web/core/lib/Drupal/Component/Utility/Mail.php
Normal file
67
web/core/lib/Drupal/Component/Utility/Mail.php
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\Utility;
|
||||
|
||||
/**
|
||||
* Provides helpers to ensure emails are compliant with RFCs.
|
||||
*
|
||||
* @ingroup utility
|
||||
*/
|
||||
class Mail {
|
||||
|
||||
/**
|
||||
* RFC-2822 "specials" characters.
|
||||
*/
|
||||
const RFC_2822_SPECIALS = '()<>[]:;@\,."';
|
||||
|
||||
/**
|
||||
* Return a RFC-2822 compliant "display-name" component.
|
||||
*
|
||||
* The "display-name" component is used in mail header "Originator" fields
|
||||
* (From, Sender, Reply-to) to give a human-friendly description of the
|
||||
* address, i.e. From: My Display Name <xyz@example.org>. RFC-822 and
|
||||
* RFC-2822 define its syntax and rules. This method gets as input a string
|
||||
* to be used as "display-name" and formats it to be RFC compliant.
|
||||
*
|
||||
* @param string $string
|
||||
* A string to be used as "display-name".
|
||||
*
|
||||
* @return string
|
||||
* A RFC compliant version of the string, ready to be used as
|
||||
* "display-name" in mail originator header fields.
|
||||
*/
|
||||
public static function formatDisplayName($string) {
|
||||
// Make sure we don't process html-encoded characters. They may create
|
||||
// unneeded trouble if left encoded, besides they will be correctly
|
||||
// processed if decoded.
|
||||
$string = Html::decodeEntities($string);
|
||||
|
||||
// If string contains non-ASCII characters it must be (short) encoded
|
||||
// according to RFC-2047. The output of a "B" (Base64) encoded-word is
|
||||
// always safe to be used as display-name.
|
||||
$safe_display_name = Unicode::mimeHeaderEncode($string, TRUE);
|
||||
|
||||
// Encoded-words are always safe to be used as display-name because don't
|
||||
// contain any RFC 2822 "specials" characters. However
|
||||
// Unicode::mimeHeaderEncode() encodes a string only if it contains any
|
||||
// non-ASCII characters, and leaves its value untouched (un-encoded) if
|
||||
// ASCII only. For this reason in order to produce a valid display-name we
|
||||
// still need to make sure there are no "specials" characters left.
|
||||
if (preg_match('/[' . preg_quote(Mail::RFC_2822_SPECIALS) . ']/', $safe_display_name)) {
|
||||
|
||||
// If string is already quoted, it may or may not be escaped properly, so
|
||||
// don't trust it and reset.
|
||||
if (preg_match('/^"(.+)"$/', $safe_display_name, $matches)) {
|
||||
$safe_display_name = str_replace(['\\\\', '\\"'], ['\\', '"'], $matches[1]);
|
||||
}
|
||||
|
||||
// Transform the string in a RFC-2822 "quoted-string" by wrapping it in
|
||||
// double-quotes. Also make sure '"' and '\' occurrences are escaped.
|
||||
$safe_display_name = '"' . str_replace(['\\', '"'], ['\\\\', '\\"'], $safe_display_name) . '"';
|
||||
|
||||
}
|
||||
|
||||
return $safe_display_name;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue