comparison vendor/zendframework/zend-escaper/src/Escaper.php @ 15:e200cb7efeb3

Update Drupal core to 8.5.3 via Composer
author Chris Cannam
date Thu, 26 Apr 2018 11:26:54 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
14:1fec387a4317 15:e200cb7efeb3
93 * @throws Exception\InvalidArgumentException 93 * @throws Exception\InvalidArgumentException
94 */ 94 */
95 public function __construct($encoding = null) 95 public function __construct($encoding = null)
96 { 96 {
97 if ($encoding !== null) { 97 if ($encoding !== null) {
98 $encoding = (string) $encoding; 98 if (! is_string($encoding)) {
99 throw new Exception\InvalidArgumentException(
100 get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding)
101 );
102 }
99 if ($encoding === '') { 103 if ($encoding === '') {
100 throw new Exception\InvalidArgumentException( 104 throw new Exception\InvalidArgumentException(
101 get_class($this) . ' constructor parameter does not allow a blank value' 105 get_class($this) . ' constructor parameter does not allow a blank value'
102 ); 106 );
103 } 107 }
104 108
105 $encoding = strtolower($encoding); 109 $encoding = strtolower($encoding);
106 if (!in_array($encoding, $this->supportedEncodings)) { 110 if (! in_array($encoding, $this->supportedEncodings)) {
107 throw new Exception\InvalidArgumentException( 111 throw new Exception\InvalidArgumentException(
108 'Value of \'' . $encoding . '\' passed to ' . get_class($this) 112 'Value of \'' . $encoding . '\' passed to ' . get_class($this)
109 . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' 113 . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()'
110 ); 114 );
111 } 115 }
319 $result = $string; 323 $result = $string;
320 } else { 324 } else {
321 $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); 325 $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding());
322 } 326 }
323 327
324 if (!$this->isUtf8($result)) { 328 if (! $this->isUtf8($result)) {
325 throw new Exception\RuntimeException( 329 throw new Exception\RuntimeException(
326 sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) 330 sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result)
327 ); 331 );
328 } 332 }
329 333