1 <?php 2 3 declare(strict_types=1); 4 /** 5 * SimplePie 6 * 7 * A PHP-Based RSS and Atom Feed Framework. 8 * Takes the hard work out of managing a complete RSS/Atom solution. 9 * 10 * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors 11 * All rights reserved. 12 * 13 * Redistribution and use in source and binary forms, with or without modification, are 14 * permitted provided that the following conditions are met: 15 * 16 * * Redistributions of source code must retain the above copyright notice, this list of 17 * conditions and the following disclaimer. 18 * 19 * * Redistributions in binary form must reproduce the above copyright notice, this list 20 * of conditions and the following disclaimer in the documentation and/or other materials 21 * provided with the distribution. 22 * 23 * * Neither the name of the SimplePie Team nor the names of its contributors may be used 24 * to endorse or promote products derived from this software without specific prior 25 * written permission. 26 * 27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 28 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 29 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS 30 * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 32 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 34 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35 * POSSIBILITY OF SUCH DAMAGE. 36 * 37 * @package SimplePie 38 * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue 39 * @author Ryan Parman 40 * @author Sam Sneddon 41 * @author Ryan McCue 42 * @link http://simplepie.org/ SimplePie 43 * @license http://www.opensource.org/licenses/bsd-license.php BSD License 44 */ 45 46 namespace SimplePie; 47 48 use SimplePie\XML\Declaration\Parser; 49 50 /** 51 * Miscellaneous utilities 52 * 53 * @package SimplePie 54 */ 55 class Misc 56 { 57 private static $SIMPLEPIE_BUILD = null; 58 59 public static function time_hms($seconds) 60 { 61 $time = ''; 62 63 $hours = floor($seconds / 3600); 64 $remainder = $seconds % 3600; 65 if ($hours > 0) { 66 $time .= $hours.':'; 67 } 68 69 $minutes = floor($remainder / 60); 70 $seconds = $remainder % 60; 71 if ($minutes < 10 && $hours > 0) { 72 $minutes = '0' . $minutes; 73 } 74 if ($seconds < 10) { 75 $seconds = '0' . $seconds; 76 } 77 78 $time .= $minutes.':'; 79 $time .= $seconds; 80 81 return $time; 82 } 83 84 public static function absolutize_url($relative, $base) 85 { 86 $iri = \SimplePie\IRI::absolutize(new \SimplePie\IRI($base), $relative); 87 if ($iri === false) { 88 return false; 89 } 90 return $iri->get_uri(); 91 } 92 93 /** 94 * Get a HTML/XML element from a HTML string 95 * 96 * @deprecated since SimplePie 1.3, use DOMDocument instead (parsing HTML with regex is bad!) 97 * @param string $realname Element name (including namespace prefix if applicable) 98 * @param string $string HTML document 99 * @return array 100 */ 101 public static function get_element($realname, $string) 102 { 103 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED); 104 105 $return = []; 106 $name = preg_quote($realname, '/'); 107 if (preg_match_all("/<($name)" . \SimplePie\SimplePie::PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) { 108 for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) { 109 $return[$i]['tag'] = $realname; 110 $return[$i]['full'] = $matches[$i][0][0]; 111 $return[$i]['offset'] = $matches[$i][0][1]; 112 if (strlen($matches[$i][3][0]) <= 2) { 113 $return[$i]['self_closing'] = true; 114 } else { 115 $return[$i]['self_closing'] = false; 116 $return[$i]['content'] = $matches[$i][4][0]; 117 } 118 $return[$i]['attribs'] = []; 119 if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) { 120 for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) { 121 if (count($attribs[$j]) === 2) { 122 $attribs[$j][2] = $attribs[$j][1]; 123 } 124 $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = Misc::entities_decode(end($attribs[$j])); 125 } 126 } 127 } 128 } 129 return $return; 130 } 131 132 public static function element_implode($element) 133 { 134 $full = "<$element[tag]"; 135 foreach ($element['attribs'] as $key => $value) { 136 $key = strtolower($key); 137 $full .= " $key=\"" . htmlspecialchars($value['data'], ENT_COMPAT, 'UTF-8') . '"'; 138 } 139 if ($element['self_closing']) { 140 $full .= ' />'; 141 } else { 142 $full .= ">$element[content]</$element[tag]>"; 143 } 144 return $full; 145 } 146 147 public static function error($message, $level, $file, $line) 148 { 149 if ((error_reporting() & $level) > 0) { 150 switch ($level) { 151 case E_USER_ERROR: 152 $note = 'PHP Error'; 153 break; 154 case E_USER_WARNING: 155 $note = 'PHP Warning'; 156 break; 157 case E_USER_NOTICE: 158 $note = 'PHP Notice'; 159 break; 160 default: 161 $note = 'Unknown Error'; 162 break; 163 } 164 165 $log_error = true; 166 if (!function_exists('error_log')) { 167 $log_error = false; 168 } 169 170 $log_file = @ini_get('error_log'); 171 if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file)) { 172 $log_error = false; 173 } 174 175 if ($log_error) { 176 @error_log("$note: $message in $file on line $line", 0); 177 } 178 } 179 180 return $message; 181 } 182 183 public static function fix_protocol($url, $http = 1) 184 { 185 $url = Misc::normalize_url($url); 186 $parsed = Misc::parse_url($url); 187 if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') { 188 return Misc::fix_protocol(Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); 189 } 190 191 if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) { 192 return Misc::fix_protocol(Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); 193 } 194 195 if ($http === 2 && $parsed['scheme'] !== '') { 196 return "feed:$url"; 197 } elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') { 198 return substr_replace($url, 'podcast', 0, 4); 199 } elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') { 200 return substr_replace($url, 'itpc', 0, 4); 201 } 202 203 return $url; 204 } 205 206 /** 207 * @deprecated since SimplePie 1.8.0, use PHP native array_replace_recursive() instead. 208 */ 209 public static function array_merge_recursive($array1, $array2) 210 { 211 foreach ($array2 as $key => $value) { 212 if (is_array($value)) { 213 $array1[$key] = Misc::array_merge_recursive($array1[$key], $value); 214 } else { 215 $array1[$key] = $value; 216 } 217 } 218 219 return $array1; 220 } 221 222 public static function parse_url($url) 223 { 224 $iri = new \SimplePie\IRI($url); 225 return [ 226 'scheme' => (string) $iri->scheme, 227 'authority' => (string) $iri->authority, 228 'path' => (string) $iri->path, 229 'query' => (string) $iri->query, 230 'fragment' => (string) $iri->fragment 231 ]; 232 } 233 234 public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') 235 { 236 $iri = new \SimplePie\IRI(''); 237 $iri->scheme = $scheme; 238 $iri->authority = $authority; 239 $iri->path = $path; 240 $iri->query = $query; 241 $iri->fragment = $fragment; 242 return $iri->get_uri(); 243 } 244 245 public static function normalize_url($url) 246 { 247 $iri = new \SimplePie\IRI($url); 248 return $iri->get_uri(); 249 } 250 251 public static function percent_encoding_normalization($match) 252 { 253 $integer = hexdec($match[1]); 254 if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) { 255 return chr($integer); 256 } 257 258 return strtoupper($match[0]); 259 } 260 261 /** 262 * Converts a Windows-1252 encoded string to a UTF-8 encoded string 263 * 264 * @static 265 * @param string $string Windows-1252 encoded string 266 * @return string UTF-8 encoded string 267 */ 268 public static function windows_1252_to_utf8($string) 269 { 270 static $convert_table = ["\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"]; 271 272 return strtr($string, $convert_table); 273 } 274 275 /** 276 * Change a string from one encoding to another 277 * 278 * @param string $data Raw data in $input encoding 279 * @param string $input Encoding of $data 280 * @param string $output Encoding you want 281 * @return string|boolean False if we can't convert it 282 */ 283 public static function change_encoding($data, $input, $output) 284 { 285 $input = Misc::encoding($input); 286 $output = Misc::encoding($output); 287 288 // We fail to fail on non US-ASCII bytes 289 if ($input === 'US-ASCII') { 290 static $non_ascii_octects = ''; 291 if (!$non_ascii_octects) { 292 for ($i = 0x80; $i <= 0xFF; $i++) { 293 $non_ascii_octects .= chr($i); 294 } 295 } 296 $data = substr($data, 0, strcspn($data, $non_ascii_octects)); 297 } 298 299 // This is first, as behaviour of this is completely predictable 300 if ($input === 'windows-1252' && $output === 'UTF-8') { 301 return Misc::windows_1252_to_utf8($data); 302 } 303 // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). 304 elseif (function_exists('mb_convert_encoding') && ($return = Misc::change_encoding_mbstring($data, $input, $output))) { 305 return $return; 306 } 307 // This is third, as behaviour of this varies with OS userland and PHP version 308 elseif (function_exists('iconv') && ($return = Misc::change_encoding_iconv($data, $input, $output))) { 309 return $return; 310 } 311 // This is last, as behaviour of this varies with OS userland and PHP version 312 elseif (class_exists('\UConverter') && ($return = Misc::change_encoding_uconverter($data, $input, $output))) { 313 return $return; 314 } 315 316 // If we can't do anything, just fail 317 return false; 318 } 319 320 protected static function change_encoding_mbstring($data, $input, $output) 321 { 322 if ($input === 'windows-949') { 323 $input = 'EUC-KR'; 324 } 325 if ($output === 'windows-949') { 326 $output = 'EUC-KR'; 327 } 328 if ($input === 'Windows-31J') { 329 $input = 'SJIS'; 330 } 331 if ($output === 'Windows-31J') { 332 $output = 'SJIS'; 333 } 334 335 // Check that the encoding is supported 336 if (!in_array($input, mb_list_encodings())) { 337 return false; 338 } 339 340 if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80") { 341 return false; 342 } 343 344 // Let's do some conversion 345 if ($return = @mb_convert_encoding($data, $output, $input)) { 346 return $return; 347 } 348 349 return false; 350 } 351 352 protected static function change_encoding_iconv($data, $input, $output) 353 { 354 return @iconv($input, $output, $data); 355 } 356 357 /** 358 * @param string $data 359 * @param string $input 360 * @param string $output 361 * @return string|false 362 */ 363 protected static function change_encoding_uconverter($data, $input, $output) 364 { 365 return @\UConverter::transcode($data, $output, $input); 366 } 367 368 /** 369 * Normalize an encoding name 370 * 371 * This is automatically generated by create.php 372 * 373 * To generate it, run `php create.php` on the command line, and copy the 374 * output to replace this function. 375 * 376 * @param string $charset Character set to standardise 377 * @return string Standardised name 378 */ 379 public static function encoding($charset) 380 { 381 // Normalization from UTS #22 382 switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) { 383 case 'adobestandardencoding': 384 case 'csadobestandardencoding': 385 return 'Adobe-Standard-Encoding'; 386 387 case 'adobesymbolencoding': 388 case 'cshppsmath': 389 return 'Adobe-Symbol-Encoding'; 390 391 case 'ami1251': 392 case 'amiga1251': 393 return 'Amiga-1251'; 394 395 case 'ansix31101983': 396 case 'csat5001983': 397 case 'csiso99naplps': 398 case 'isoir99': 399 case 'naplps': 400 return 'ANSI_X3.110-1983'; 401 402 case 'arabic7': 403 case 'asmo449': 404 case 'csiso89asmo449': 405 case 'iso9036': 406 case 'isoir89': 407 return 'ASMO_449'; 408 409 case 'big5': 410 case 'csbig5': 411 return 'Big5'; 412 413 case 'big5hkscs': 414 return 'Big5-HKSCS'; 415 416 case 'bocu1': 417 case 'csbocu1': 418 return 'BOCU-1'; 419 420 case 'brf': 421 case 'csbrf': 422 return 'BRF'; 423 424 case 'bs4730': 425 case 'csiso4unitedkingdom': 426 case 'gb': 427 case 'iso646gb': 428 case 'isoir4': 429 case 'uk': 430 return 'BS_4730'; 431 432 case 'bsviewdata': 433 case 'csiso47bsviewdata': 434 case 'isoir47': 435 return 'BS_viewdata'; 436 437 case 'cesu8': 438 case 'cscesu8': 439 return 'CESU-8'; 440 441 case 'ca': 442 case 'csa71': 443 case 'csaz243419851': 444 case 'csiso121canadian1': 445 case 'iso646ca': 446 case 'isoir121': 447 return 'CSA_Z243.4-1985-1'; 448 449 case 'csa72': 450 case 'csaz243419852': 451 case 'csiso122canadian2': 452 case 'iso646ca2': 453 case 'isoir122': 454 return 'CSA_Z243.4-1985-2'; 455 456 case 'csaz24341985gr': 457 case 'csiso123csaz24341985gr': 458 case 'isoir123': 459 return 'CSA_Z243.4-1985-gr'; 460 461 case 'csiso139csn369103': 462 case 'csn369103': 463 case 'isoir139': 464 return 'CSN_369103'; 465 466 case 'csdecmcs': 467 case 'dec': 468 case 'decmcs': 469 return 'DEC-MCS'; 470 471 case 'csiso21german': 472 case 'de': 473 case 'din66003': 474 case 'iso646de': 475 case 'isoir21': 476 return 'DIN_66003'; 477 478 case 'csdkus': 479 case 'dkus': 480 return 'dk-us'; 481 482 case 'csiso646danish': 483 case 'dk': 484 case 'ds2089': 485 case 'iso646dk': 486 return 'DS_2089'; 487 488 case 'csibmebcdicatde': 489 case 'ebcdicatde': 490 return 'EBCDIC-AT-DE'; 491 492 case 'csebcdicatdea': 493 case 'ebcdicatdea': 494 return 'EBCDIC-AT-DE-A'; 495 496 case 'csebcdiccafr': 497 case 'ebcdiccafr': 498 return 'EBCDIC-CA-FR'; 499 500 case 'csebcdicdkno': 501 case 'ebcdicdkno': 502 return 'EBCDIC-DK-NO'; 503 504 case 'csebcdicdknoa': 505 case 'ebcdicdknoa': 506 return 'EBCDIC-DK-NO-A'; 507 508 case 'csebcdices': 509 case 'ebcdices': 510 return 'EBCDIC-ES'; 511 512 case 'csebcdicesa': 513 case 'ebcdicesa': 514 return 'EBCDIC-ES-A'; 515 516 case 'csebcdicess': 517 case 'ebcdicess': 518 return 'EBCDIC-ES-S'; 519 520 case 'csebcdicfise': 521 case 'ebcdicfise': 522 return 'EBCDIC-FI-SE'; 523 524 case 'csebcdicfisea': 525 case 'ebcdicfisea': 526 return 'EBCDIC-FI-SE-A'; 527 528 case 'csebcdicfr': 529 case 'ebcdicfr': 530 return 'EBCDIC-FR'; 531 532 case 'csebcdicit': 533 case 'ebcdicit': 534 return 'EBCDIC-IT'; 535 536 case 'csebcdicpt': 537 case 'ebcdicpt': 538 return 'EBCDIC-PT'; 539 540 case 'csebcdicuk': 541 case 'ebcdicuk': 542 return 'EBCDIC-UK'; 543 544 case 'csebcdicus': 545 case 'ebcdicus': 546 return 'EBCDIC-US'; 547 548 case 'csiso111ecmacyrillic': 549 case 'ecmacyrillic': 550 case 'isoir111': 551 case 'koi8e': 552 return 'ECMA-cyrillic'; 553 554 case 'csiso17spanish': 555 case 'es': 556 case 'iso646es': 557 case 'isoir17': 558 return 'ES'; 559 560 case 'csiso85spanish2': 561 case 'es2': 562 case 'iso646es2': 563 case 'isoir85': 564 return 'ES2'; 565 566 case 'cseucpkdfmtjapanese': 567 case 'eucjp': 568 case 'extendedunixcodepackedformatforjapanese': 569 return 'EUC-JP'; 570 571 case 'cseucfixwidjapanese': 572 case 'extendedunixcodefixedwidthforjapanese': 573 return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; 574 575 case 'gb18030': 576 return 'GB18030'; 577 578 case 'chinese': 579 case 'cp936': 580 case 'csgb2312': 581 case 'csiso58gb231280': 582 case 'gb2312': 583 case 'gb231280': 584 case 'gbk': 585 case 'isoir58': 586 case 'ms936': 587 case 'windows936': 588 return 'GBK'; 589 590 case 'cn': 591 case 'csiso57gb1988': 592 case 'gb198880': 593 case 'iso646cn': 594 case 'isoir57': 595 return 'GB_1988-80'; 596 597 case 'csiso153gost1976874': 598 case 'gost1976874': 599 case 'isoir153': 600 case 'stsev35888': 601 return 'GOST_19768-74'; 602 603 case 'csiso150': 604 case 'csiso150greekccitt': 605 case 'greekccitt': 606 case 'isoir150': 607 return 'greek-ccitt'; 608 609 case 'csiso88greek7': 610 case 'greek7': 611 case 'isoir88': 612 return 'greek7'; 613 614 case 'csiso18greek7old': 615 case 'greek7old': 616 case 'isoir18': 617 return 'greek7-old'; 618 619 case 'cshpdesktop': 620 case 'hpdesktop': 621 return 'HP-DeskTop'; 622 623 case 'cshplegal': 624 case 'hplegal': 625 return 'HP-Legal'; 626 627 case 'cshpmath8': 628 case 'hpmath8': 629 return 'HP-Math8'; 630 631 case 'cshppifont': 632 case 'hppifont': 633 return 'HP-Pi-font'; 634 635 case 'cshproman8': 636 case 'hproman8': 637 case 'r8': 638 case 'roman8': 639 return 'hp-roman8'; 640 641 case 'hzgb2312': 642 return 'HZ-GB-2312'; 643 644 case 'csibmsymbols': 645 case 'ibmsymbols': 646 return 'IBM-Symbols'; 647 648 case 'csibmthai': 649 case 'ibmthai': 650 return 'IBM-Thai'; 651 652 case 'cp37': 653 case 'csibm37': 654 case 'ebcdiccpca': 655 case 'ebcdiccpnl': 656 case 'ebcdiccpus': 657 case 'ebcdiccpwt': 658 case 'ibm37': 659 return 'IBM037'; 660 661 case 'cp38': 662 case 'csibm38': 663 case 'ebcdicint': 664 case 'ibm38': 665 return 'IBM038'; 666 667 case 'cp273': 668 case 'csibm273': 669 case 'ibm273': 670 return 'IBM273'; 671 672 case 'cp274': 673 case 'csibm274': 674 case 'ebcdicbe': 675 case 'ibm274': 676 return 'IBM274'; 677 678 case 'cp275': 679 case 'csibm275': 680 case 'ebcdicbr': 681 case 'ibm275': 682 return 'IBM275'; 683 684 case 'csibm277': 685 case 'ebcdiccpdk': 686 case 'ebcdiccpno': 687 case 'ibm277': 688 return 'IBM277'; 689 690 case 'cp278': 691 case 'csibm278': 692 case 'ebcdiccpfi': 693 case 'ebcdiccpse': 694 case 'ibm278': 695 return 'IBM278'; 696 697 case 'cp280': 698 case 'csibm280': 699 case 'ebcdiccpit': 700 case 'ibm280': 701 return 'IBM280'; 702 703 case 'cp281': 704 case 'csibm281': 705 case 'ebcdicjpe': 706 case 'ibm281': 707 return 'IBM281'; 708 709 case 'cp284': 710 case 'csibm284': 711 case 'ebcdiccpes': 712 case 'ibm284': 713 return 'IBM284'; 714 715 case 'cp285': 716 case 'csibm285': 717 case 'ebcdiccpgb': 718 case 'ibm285': 719 return 'IBM285'; 720 721 case 'cp290': 722 case 'csibm290': 723 case 'ebcdicjpkana': 724 case 'ibm290': 725 return 'IBM290'; 726 727 case 'cp297': 728 case 'csibm297': 729 case 'ebcdiccpfr': 730 case 'ibm297': 731 return 'IBM297'; 732 733 case 'cp420': 734 case 'csibm420': 735 case 'ebcdiccpar1': 736 case 'ibm420': 737 return 'IBM420'; 738 739 case 'cp423': 740 case 'csibm423': 741 case 'ebcdiccpgr': 742 case 'ibm423': 743 return 'IBM423'; 744 745 case 'cp424': 746 case 'csibm424': 747 case 'ebcdiccphe': 748 case 'ibm424': 749 return 'IBM424'; 750 751 case '437': 752 case 'cp437': 753 case 'cspc8codepage437': 754 case 'ibm437': 755 return 'IBM437'; 756 757 case 'cp500': 758 case 'csibm500': 759 case 'ebcdiccpbe': 760 case 'ebcdiccpch': 761 case 'ibm500': 762 return 'IBM500'; 763 764 case 'cp775': 765 case 'cspc775baltic': 766 case 'ibm775': 767 return 'IBM775'; 768 769 case '850': 770 case 'cp850': 771 case 'cspc850multilingual': 772 case 'ibm850': 773 return 'IBM850'; 774 775 case '851': 776 case 'cp851': 777 case 'csibm851': 778 case 'ibm851': 779 return 'IBM851'; 780 781 case '852': 782 case 'cp852': 783 case 'cspcp852': 784 case 'ibm852': 785 return 'IBM852'; 786 787 case '855': 788 case 'cp855': 789 case 'csibm855': 790 case 'ibm855': 791 return 'IBM855'; 792 793 case '857': 794 case 'cp857': 795 case 'csibm857': 796 case 'ibm857': 797 return 'IBM857'; 798 799 case 'ccsid858': 800 case 'cp858': 801 case 'ibm858': 802 case 'pcmultilingual850euro': 803 return 'IBM00858'; 804 805 case '860': 806 case 'cp860': 807 case 'csibm860': 808 case 'ibm860': 809 return 'IBM860'; 810 811 case '861': 812 case 'cp861': 813 case 'cpis': 814 case 'csibm861': 815 case 'ibm861': 816 return 'IBM861'; 817 818 case '862': 819 case 'cp862': 820 case 'cspc862latinhebrew': 821 case 'ibm862': 822 return 'IBM862'; 823 824 case '863': 825 case 'cp863': 826 case 'csibm863': 827 case 'ibm863': 828 return 'IBM863'; 829 830 case 'cp864': 831 case 'csibm864': 832 case 'ibm864': 833 return 'IBM864'; 834 835 case '865': 836 case 'cp865': 837 case 'csibm865': 838 case 'ibm865': 839 return 'IBM865'; 840 841 case '866': 842 case 'cp866': 843 case 'csibm866': 844 case 'ibm866': 845 return 'IBM866'; 846 847 case 'cp868': 848 case 'cpar': 849 case 'csibm868': 850 case 'ibm868': 851 return 'IBM868'; 852 853 case '869': 854 case 'cp869': 855 case 'cpgr': 856 case 'csibm869': 857 case 'ibm869': 858 return 'IBM869'; 859 860 case 'cp870': 861 case 'csibm870': 862 case 'ebcdiccproece': 863 case 'ebcdiccpyu': 864 case 'ibm870': 865 return 'IBM870'; 866 867 case 'cp871': 868 case 'csibm871': 869 case 'ebcdiccpis': 870 case 'ibm871': 871 return 'IBM871'; 872 873 case 'cp880': 874 case 'csibm880': 875 case 'ebcdiccyrillic': 876 case 'ibm880': 877 return 'IBM880'; 878 879 case 'cp891': 880 case 'csibm891': 881 case 'ibm891': 882 return 'IBM891'; 883 884 case 'cp903': 885 case 'csibm903': 886 case 'ibm903': 887 return 'IBM903'; 888 889 case '904': 890 case 'cp904': 891 case 'csibbm904': 892 case 'ibm904': 893 return 'IBM904'; 894 895 case 'cp905': 896 case 'csibm905': 897 case 'ebcdiccptr': 898 case 'ibm905': 899 return 'IBM905'; 900 901 case 'cp918': 902 case 'csibm918': 903 case 'ebcdiccpar2': 904 case 'ibm918': 905 return 'IBM918'; 906 907 case 'ccsid924': 908 case 'cp924': 909 case 'ebcdiclatin9euro': 910 case 'ibm924': 911 return 'IBM00924'; 912 913 case 'cp1026': 914 case 'csibm1026': 915 case 'ibm1026': 916 return 'IBM1026'; 917 918 case 'ibm1047': 919 return 'IBM1047'; 920 921 case 'ccsid1140': 922 case 'cp1140': 923 case 'ebcdicus37euro': 924 case 'ibm1140': 925 return 'IBM01140'; 926 927 case 'ccsid1141': 928 case 'cp1141': 929 case 'ebcdicde273euro': 930 case 'ibm1141': 931 return 'IBM01141'; 932 933 case 'ccsid1142': 934 case 'cp1142': 935 case 'ebcdicdk277euro': 936 case 'ebcdicno277euro': 937 case 'ibm1142': 938 return 'IBM01142'; 939 940 case 'ccsid1143': 941 case 'cp1143': 942 case 'ebcdicfi278euro': 943 case 'ebcdicse278euro': 944 case 'ibm1143': 945 return 'IBM01143'; 946 947 case 'ccsid1144': 948 case 'cp1144': 949 case 'ebcdicit280euro': 950 case 'ibm1144': 951 return 'IBM01144'; 952 953 case 'ccsid1145': 954 case 'cp1145': 955 case 'ebcdices284euro': 956 case 'ibm1145': 957 return 'IBM01145'; 958 959 case 'ccsid1146': 960 case 'cp1146': 961 case 'ebcdicgb285euro': 962 case 'ibm1146': 963 return 'IBM01146'; 964 965 case 'ccsid1147': 966 case 'cp1147': 967 case 'ebcdicfr297euro': 968 case 'ibm1147': 969 return 'IBM01147'; 970 971 case 'ccsid1148': 972 case 'cp1148': 973 case 'ebcdicinternational500euro': 974 case 'ibm1148': 975 return 'IBM01148'; 976 977 case 'ccsid1149': 978 case 'cp1149': 979 case 'ebcdicis871euro': 980 case 'ibm1149': 981 return 'IBM01149'; 982 983 case 'csiso143iecp271': 984 case 'iecp271': 985 case 'isoir143': 986 return 'IEC_P27-1'; 987 988 case 'csiso49inis': 989 case 'inis': 990 case 'isoir49': 991 return 'INIS'; 992 993 case 'csiso50inis8': 994 case 'inis8': 995 case 'isoir50': 996 return 'INIS-8'; 997 998 case 'csiso51iniscyrillic': 999 case 'iniscyrillic': 1000 case 'isoir51': 1001 return 'INIS-cyrillic'; 1002 1003 case 'csinvariant': 1004 case 'invariant': 1005 return 'INVARIANT'; 1006 1007 case 'iso2022cn': 1008 return 'ISO-2022-CN'; 1009 1010 case 'iso2022cnext': 1011 return 'ISO-2022-CN-EXT'; 1012 1013 case 'csiso2022jp': 1014 case 'iso2022jp': 1015 return 'ISO-2022-JP'; 1016 1017 case 'csiso2022jp2': 1018 case 'iso2022jp2': 1019 return 'ISO-2022-JP-2'; 1020 1021 case 'csiso2022kr': 1022 case 'iso2022kr': 1023 return 'ISO-2022-KR'; 1024 1025 case 'cswindows30latin1': 1026 case 'iso88591windows30latin1': 1027 return 'ISO-8859-1-Windows-3.0-Latin-1'; 1028 1029 case 'cswindows31latin1': 1030 case 'iso88591windows31latin1': 1031 return 'ISO-8859-1-Windows-3.1-Latin-1'; 1032 1033 case 'csisolatin2': 1034 case 'iso88592': 1035 case 'iso885921987': 1036 case 'isoir101': 1037 case 'l2': 1038 case 'latin2': 1039 return 'ISO-8859-2'; 1040 1041 case 'cswindows31latin2': 1042 case 'iso88592windowslatin2': 1043 return 'ISO-8859-2-Windows-Latin-2'; 1044 1045 case 'csisolatin3': 1046 case 'iso88593': 1047 case 'iso885931988': 1048 case 'isoir109': 1049 case 'l3': 1050 case 'latin3': 1051 return 'ISO-8859-3'; 1052 1053 case 'csisolatin4': 1054 case 'iso88594': 1055 case 'iso885941988': 1056 case 'isoir110': 1057 case 'l4': 1058 case 'latin4': 1059 return 'ISO-8859-4'; 1060 1061 case 'csisolatincyrillic': 1062 case 'cyrillic': 1063 case 'iso88595': 1064 case 'iso885951988': 1065 case 'isoir144': 1066 return 'ISO-8859-5'; 1067 1068 case 'arabic': 1069 case 'asmo708': 1070 case 'csisolatinarabic': 1071 case 'ecma114': 1072 case 'iso88596': 1073 case 'iso885961987': 1074 case 'isoir127': 1075 return 'ISO-8859-6'; 1076 1077 case 'csiso88596e': 1078 case 'iso88596e': 1079 return 'ISO-8859-6-E'; 1080 1081 case 'csiso88596i': 1082 case 'iso88596i': 1083 return 'ISO-8859-6-I'; 1084 1085 case 'csisolatingreek': 1086 case 'ecma118': 1087 case 'elot928': 1088 case 'greek': 1089 case 'greek8': 1090 case 'iso88597': 1091 case 'iso885971987': 1092 case 'isoir126': 1093 return 'ISO-8859-7'; 1094 1095 case 'csisolatinhebrew': 1096 case 'hebrew': 1097 case 'iso88598': 1098 case 'iso885981988': 1099 case 'isoir138': 1100 return 'ISO-8859-8'; 1101 1102 case 'csiso88598e': 1103 case 'iso88598e': 1104 return 'ISO-8859-8-E'; 1105 1106 case 'csiso88598i': 1107 case 'iso88598i': 1108 return 'ISO-8859-8-I'; 1109 1110 case 'cswindows31latin5': 1111 case 'iso88599windowslatin5': 1112 return 'ISO-8859-9-Windows-Latin-5'; 1113 1114 case 'csisolatin6': 1115 case 'iso885910': 1116 case 'iso8859101992': 1117 case 'isoir157': 1118 case 'l6': 1119 case 'latin6': 1120 return 'ISO-8859-10'; 1121 1122 case 'iso885913': 1123 return 'ISO-8859-13'; 1124 1125 case 'iso885914': 1126 case 'iso8859141998': 1127 case 'isoceltic': 1128 case 'isoir199': 1129 case 'l8': 1130 case 'latin8': 1131 return 'ISO-8859-14'; 1132 1133 case 'iso885915': 1134 case 'latin9': 1135 return 'ISO-8859-15'; 1136 1137 case 'iso885916': 1138 case 'iso8859162001': 1139 case 'isoir226': 1140 case 'l10': 1141 case 'latin10': 1142 return 'ISO-8859-16'; 1143 1144 case 'iso10646j1': 1145 return 'ISO-10646-J-1'; 1146 1147 case 'csunicode': 1148 case 'iso10646ucs2': 1149 return 'ISO-10646-UCS-2'; 1150 1151 case 'csucs4': 1152 case 'iso10646ucs4': 1153 return 'ISO-10646-UCS-4'; 1154 1155 case 'csunicodeascii': 1156 case 'iso10646ucsbasic': 1157 return 'ISO-10646-UCS-Basic'; 1158 1159 case 'csunicodelatin1': 1160 case 'iso10646': 1161 case 'iso10646unicodelatin1': 1162 return 'ISO-10646-Unicode-Latin1'; 1163 1164 case 'csiso10646utf1': 1165 case 'iso10646utf1': 1166 return 'ISO-10646-UTF-1'; 1167 1168 case 'csiso115481': 1169 case 'iso115481': 1170 case 'isotr115481': 1171 return 'ISO-11548-1'; 1172 1173 case 'csiso90': 1174 case 'isoir90': 1175 return 'iso-ir-90'; 1176 1177 case 'csunicodeibm1261': 1178 case 'isounicodeibm1261': 1179 return 'ISO-Unicode-IBM-1261'; 1180 1181 case 'csunicodeibm1264': 1182 case 'isounicodeibm1264': 1183 return 'ISO-Unicode-IBM-1264'; 1184 1185 case 'csunicodeibm1265': 1186 case 'isounicodeibm1265': 1187 return 'ISO-Unicode-IBM-1265'; 1188 1189 case 'csunicodeibm1268': 1190 case 'isounicodeibm1268': 1191 return 'ISO-Unicode-IBM-1268'; 1192 1193 case 'csunicodeibm1276': 1194 case 'isounicodeibm1276': 1195 return 'ISO-Unicode-IBM-1276'; 1196 1197 case 'csiso646basic1983': 1198 case 'iso646basic1983': 1199 case 'ref': 1200 return 'ISO_646.basic:1983'; 1201 1202 case 'csiso2intlrefversion': 1203 case 'irv': 1204 case 'iso646irv1983': 1205 case 'isoir2': 1206 return 'ISO_646.irv:1983'; 1207 1208 case 'csiso2033': 1209 case 'e13b': 1210 case 'iso20331983': 1211 case 'isoir98': 1212 return 'ISO_2033-1983'; 1213 1214 case 'csiso5427cyrillic': 1215 case 'iso5427': 1216 case 'isoir37': 1217 return 'ISO_5427'; 1218 1219 case 'iso5427cyrillic1981': 1220 case 'iso54271981': 1221 case 'isoir54': 1222 return 'ISO_5427:1981'; 1223 1224 case 'csiso5428greek': 1225 case 'iso54281980': 1226 case 'isoir55': 1227 return 'ISO_5428:1980'; 1228 1229 case 'csiso6937add': 1230 case 'iso6937225': 1231 case 'isoir152': 1232 return 'ISO_6937-2-25'; 1233 1234 case 'csisotextcomm': 1235 case 'iso69372add': 1236 case 'isoir142': 1237 return 'ISO_6937-2-add'; 1238 1239 case 'csiso8859supp': 1240 case 'iso8859supp': 1241 case 'isoir154': 1242 case 'latin125': 1243 return 'ISO_8859-supp'; 1244 1245 case 'csiso10367box': 1246 case 'iso10367box': 1247 case 'isoir155': 1248 return 'ISO_10367-box'; 1249 1250 case 'csiso15italian': 1251 case 'iso646it': 1252 case 'isoir15': 1253 case 'it': 1254 return 'IT'; 1255 1256 case 'csiso13jisc6220jp': 1257 case 'isoir13': 1258 case 'jisc62201969': 1259 case 'jisc62201969jp': 1260 case 'katakana': 1261 case 'x2017': 1262 return 'JIS_C6220-1969-jp'; 1263 1264 case 'csiso14jisc6220ro': 1265 case 'iso646jp': 1266 case 'isoir14': 1267 case 'jisc62201969ro': 1268 case 'jp': 1269 return 'JIS_C6220-1969-ro'; 1270 1271 case 'csiso42jisc62261978': 1272 case 'isoir42': 1273 case 'jisc62261978': 1274 return 'JIS_C6226-1978'; 1275 1276 case 'csiso87jisx208': 1277 case 'isoir87': 1278 case 'jisc62261983': 1279 case 'jisx2081983': 1280 case 'x208': 1281 return 'JIS_C6226-1983'; 1282 1283 case 'csiso91jisc62291984a': 1284 case 'isoir91': 1285 case 'jisc62291984a': 1286 case 'jpocra': 1287 return 'JIS_C6229-1984-a'; 1288 1289 case 'csiso92jisc62991984b': 1290 case 'iso646jpocrb': 1291 case 'isoir92': 1292 case 'jisc62291984b': 1293 case 'jpocrb': 1294 return 'JIS_C6229-1984-b'; 1295 1296 case 'csiso93jis62291984badd': 1297 case 'isoir93': 1298 case 'jisc62291984badd': 1299 case 'jpocrbadd': 1300 return 'JIS_C6229-1984-b-add'; 1301 1302 case 'csiso94jis62291984hand': 1303 case 'isoir94': 1304 case 'jisc62291984hand': 1305 case 'jpocrhand': 1306 return 'JIS_C6229-1984-hand'; 1307 1308 case 'csiso95jis62291984handadd': 1309 case 'isoir95': 1310 case 'jisc62291984handadd': 1311 case 'jpocrhandadd': 1312 return 'JIS_C6229-1984-hand-add'; 1313 1314 case 'csiso96jisc62291984kana': 1315 case 'isoir96': 1316 case 'jisc62291984kana': 1317 return 'JIS_C6229-1984-kana'; 1318 1319 case 'csjisencoding': 1320 case 'jisencoding': 1321 return 'JIS_Encoding'; 1322 1323 case 'cshalfwidthkatakana': 1324 case 'jisx201': 1325 case 'x201': 1326 return 'JIS_X0201'; 1327 1328 case 'csiso159jisx2121990': 1329 case 'isoir159': 1330 case 'jisx2121990': 1331 case 'x212': 1332 return 'JIS_X0212-1990'; 1333 1334 case 'csiso141jusib1002': 1335 case 'iso646yu': 1336 case 'isoir141': 1337 case 'js': 1338 case 'jusib1002': 1339 case 'yu': 1340 return 'JUS_I.B1.002'; 1341 1342 case 'csiso147macedonian': 1343 case 'isoir147': 1344 case 'jusib1003mac': 1345 case 'macedonian': 1346 return 'JUS_I.B1.003-mac'; 1347 1348 case 'csiso146serbian': 1349 case 'isoir146': 1350 case 'jusib1003serb': 1351 case 'serbian': 1352 return 'JUS_I.B1.003-serb'; 1353 1354 case 'koi7switched': 1355 return 'KOI7-switched'; 1356 1357 case 'cskoi8r': 1358 case 'koi8r': 1359 return 'KOI8-R'; 1360 1361 case 'koi8u': 1362 return 'KOI8-U'; 1363 1364 case 'csksc5636': 1365 case 'iso646kr': 1366 case 'ksc5636': 1367 return 'KSC5636'; 1368 1369 case 'cskz1048': 1370 case 'kz1048': 1371 case 'rk1048': 1372 case 'strk10482002': 1373 return 'KZ-1048'; 1374 1375 case 'csiso19latingreek': 1376 case 'isoir19': 1377 case 'latingreek': 1378 return 'latin-greek'; 1379 1380 case 'csiso27latingreek1': 1381 case 'isoir27': 1382 case 'latingreek1': 1383 return 'Latin-greek-1'; 1384 1385 case 'csiso158lap': 1386 case 'isoir158': 1387 case 'lap': 1388 case 'latinlap': 1389 return 'latin-lap'; 1390 1391 case 'csmacintosh': 1392 case 'mac': 1393 case 'macintosh': 1394 return 'macintosh'; 1395 1396 case 'csmicrosoftpublishing': 1397 case 'microsoftpublishing': 1398 return 'Microsoft-Publishing'; 1399 1400 case 'csmnem': 1401 case 'mnem': 1402 return 'MNEM'; 1403 1404 case 'csmnemonic': 1405 case 'mnemonic': 1406 return 'MNEMONIC'; 1407 1408 case 'csiso86hungarian': 1409 case 'hu': 1410 case 'iso646hu': 1411 case 'isoir86': 1412 case 'msz77953': 1413 return 'MSZ_7795.3'; 1414 1415 case 'csnatsdano': 1416 case 'isoir91': 1417 case 'natsdano': 1418 return 'NATS-DANO'; 1419 1420 case 'csnatsdanoadd': 1421 case 'isoir92': 1422 case 'natsdanoadd': 1423 return 'NATS-DANO-ADD'; 1424 1425 case 'csnatssefi': 1426 case 'isoir81': 1427 case 'natssefi': 1428 return 'NATS-SEFI'; 1429 1430 case 'csnatssefiadd': 1431 case 'isoir82': 1432 case 'natssefiadd': 1433 return 'NATS-SEFI-ADD'; 1434 1435 case 'csiso151cuba': 1436 case 'cuba': 1437 case 'iso646cu': 1438 case 'isoir151': 1439 case 'ncnc1081': 1440 return 'NC_NC00-10:81'; 1441 1442 case 'csiso69french': 1443 case 'fr': 1444 case 'iso646fr': 1445 case 'isoir69': 1446 case 'nfz62010': 1447 return 'NF_Z_62-010'; 1448 1449 case 'csiso25french': 1450 case 'iso646fr1': 1451 case 'isoir25': 1452 case 'nfz620101973': 1453 return 'NF_Z_62-010_(1973)'; 1454 1455 case 'csiso60danishnorwegian': 1456 case 'csiso60norwegian1': 1457 case 'iso646no': 1458 case 'isoir60': 1459 case 'no': 1460 case 'ns45511': 1461 return 'NS_4551-1'; 1462 1463 case 'csiso61norwegian2': 1464 case 'iso646no2': 1465 case 'isoir61': 1466 case 'no2': 1467 case 'ns45512': 1468 return 'NS_4551-2'; 1469 1470 case 'osdebcdicdf3irv': 1471 return 'OSD_EBCDIC_DF03_IRV'; 1472 1473 case 'osdebcdicdf41': 1474 return 'OSD_EBCDIC_DF04_1'; 1475 1476 case 'osdebcdicdf415': 1477 return 'OSD_EBCDIC_DF04_15'; 1478 1479 case 'cspc8danishnorwegian': 1480 case 'pc8danishnorwegian': 1481 return 'PC8-Danish-Norwegian'; 1482 1483 case 'cspc8turkish': 1484 case 'pc8turkish': 1485 return 'PC8-Turkish'; 1486 1487 case 'csiso16portuguese': 1488 case 'iso646pt': 1489 case 'isoir16': 1490 case 'pt': 1491 return 'PT'; 1492 1493 case 'csiso84portuguese2': 1494 case 'iso646pt2': 1495 case 'isoir84': 1496 case 'pt2': 1497 return 'PT2'; 1498 1499 case 'cp154': 1500 case 'csptcp154': 1501 case 'cyrillicasian': 1502 case 'pt154': 1503 case 'ptcp154': 1504 return 'PTCP154'; 1505 1506 case 'scsu': 1507 return 'SCSU'; 1508 1509 case 'csiso10swedish': 1510 case 'fi': 1511 case 'iso646fi': 1512 case 'iso646se': 1513 case 'isoir10': 1514 case 'se': 1515 case 'sen850200b': 1516 return 'SEN_850200_B'; 1517 1518 case 'csiso11swedishfornames': 1519 case 'iso646se2': 1520 case 'isoir11': 1521 case 'se2': 1522 case 'sen850200c': 1523 return 'SEN_850200_C'; 1524 1525 case 'csiso102t617bit': 1526 case 'isoir102': 1527 case 't617bit': 1528 return 'T.61-7bit'; 1529 1530 case 'csiso103t618bit': 1531 case 'isoir103': 1532 case 't61': 1533 case 't618bit': 1534 return 'T.61-8bit'; 1535 1536 case 'csiso128t101g2': 1537 case 'isoir128': 1538 case 't101g2': 1539 return 'T.101-G2'; 1540 1541 case 'cstscii': 1542 case 'tscii': 1543 return 'TSCII'; 1544 1545 case 'csunicode11': 1546 case 'unicode11': 1547 return 'UNICODE-1-1'; 1548 1549 case 'csunicode11utf7': 1550 case 'unicode11utf7': 1551 return 'UNICODE-1-1-UTF-7'; 1552 1553 case 'csunknown8bit': 1554 case 'unknown8bit': 1555 return 'UNKNOWN-8BIT'; 1556 1557 case 'ansix341968': 1558 case 'ansix341986': 1559 case 'ascii': 1560 case 'cp367': 1561 case 'csascii': 1562 case 'ibm367': 1563 case 'iso646irv1991': 1564 case 'iso646us': 1565 case 'isoir6': 1566 case 'us': 1567 case 'usascii': 1568 return 'US-ASCII'; 1569 1570 case 'csusdk': 1571 case 'usdk': 1572 return 'us-dk'; 1573 1574 case 'utf7': 1575 return 'UTF-7'; 1576 1577 case 'utf8': 1578 return 'UTF-8'; 1579 1580 case 'utf16': 1581 return 'UTF-16'; 1582 1583 case 'utf16be': 1584 return 'UTF-16BE'; 1585 1586 case 'utf16le': 1587 return 'UTF-16LE'; 1588 1589 case 'utf32': 1590 return 'UTF-32'; 1591 1592 case 'utf32be': 1593 return 'UTF-32BE'; 1594 1595 case 'utf32le': 1596 return 'UTF-32LE'; 1597 1598 case 'csventurainternational': 1599 case 'venturainternational': 1600 return 'Ventura-International'; 1601 1602 case 'csventuramath': 1603 case 'venturamath': 1604 return 'Ventura-Math'; 1605 1606 case 'csventuraus': 1607 case 'venturaus': 1608 return 'Ventura-US'; 1609 1610 case 'csiso70videotexsupp1': 1611 case 'isoir70': 1612 case 'videotexsuppl': 1613 return 'videotex-suppl'; 1614 1615 case 'csviqr': 1616 case 'viqr': 1617 return 'VIQR'; 1618 1619 case 'csviscii': 1620 case 'viscii': 1621 return 'VISCII'; 1622 1623 case 'csshiftjis': 1624 case 'cswindows31j': 1625 case 'mskanji': 1626 case 'shiftjis': 1627 case 'windows31j': 1628 return 'Windows-31J'; 1629 1630 case 'iso885911': 1631 case 'tis620': 1632 return 'windows-874'; 1633 1634 case 'cseuckr': 1635 case 'csksc56011987': 1636 case 'euckr': 1637 case 'isoir149': 1638 case 'korean': 1639 case 'ksc5601': 1640 case 'ksc56011987': 1641 case 'ksc56011989': 1642 case 'windows949': 1643 return 'windows-949'; 1644 1645 case 'windows1250': 1646 return 'windows-1250'; 1647 1648 case 'windows1251': 1649 return 'windows-1251'; 1650 1651 case 'cp819': 1652 case 'csisolatin1': 1653 case 'ibm819': 1654 case 'iso88591': 1655 case 'iso885911987': 1656 case 'isoir100': 1657 case 'l1': 1658 case 'latin1': 1659 case 'windows1252': 1660 return 'windows-1252'; 1661 1662 case 'windows1253': 1663 return 'windows-1253'; 1664 1665 case 'csisolatin5': 1666 case 'iso88599': 1667 case 'iso885991989': 1668 case 'isoir148': 1669 case 'l5': 1670 case 'latin5': 1671 case 'windows1254': 1672 return 'windows-1254'; 1673 1674 case 'windows1255': 1675 return 'windows-1255'; 1676 1677 case 'windows1256': 1678 return 'windows-1256'; 1679 1680 case 'windows1257': 1681 return 'windows-1257'; 1682 1683 case 'windows1258': 1684 return 'windows-1258'; 1685 1686 default: 1687 return $charset; 1688 } 1689 } 1690 1691 public static function get_curl_version() 1692 { 1693 if (is_array($curl = curl_version())) { 1694 $curl = $curl['version']; 1695 } elseif (substr($curl, 0, 5) === 'curl/') { 1696 $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); 1697 } elseif (substr($curl, 0, 8) === 'libcurl/') { 1698 $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); 1699 } else { 1700 $curl = 0; 1701 } 1702 return $curl; 1703 } 1704 1705 /** 1706 * Strip HTML comments 1707 * 1708 * @param string $data Data to strip comments from 1709 * @return string Comment stripped string 1710 */ 1711 public static function strip_comments($data) 1712 { 1713 $output = ''; 1714 while (($start = strpos($data, '<!--')) !== false) { 1715 $output .= substr($data, 0, $start); 1716 if (($end = strpos($data, '-->', $start)) !== false) { 1717 $data = substr_replace($data, '', 0, $end + 3); 1718 } else { 1719 $data = ''; 1720 } 1721 } 1722 return $output . $data; 1723 } 1724 1725 public static function parse_date($dt) 1726 { 1727 $parser = \SimplePie\Parse\Date::get(); 1728 return $parser->parse($dt); 1729 } 1730 1731 /** 1732 * Decode HTML entities 1733 * 1734 * @deprecated since SimplePie 1.3, use DOMDocument instead 1735 * @param string $data Input data 1736 * @return string Output data 1737 */ 1738 public static function entities_decode($data) 1739 { 1740 // trigger_error(sprintf('Using method "' . __METHOD__ . '" is deprecated since SimplePie 1.3, use "DOMDocument" instead.'), \E_USER_DEPRECATED); 1741 1742 $decoder = new \SimplePie_Decode_HTML_Entities($data); 1743 return $decoder->parse(); 1744 } 1745 1746 /** 1747 * Remove RFC822 comments 1748 * 1749 * @param string $data Data to strip comments from 1750 * @return string Comment stripped string 1751 */ 1752 public static function uncomment_rfc822($string) 1753 { 1754 $string = (string) $string; 1755 $position = 0; 1756 $length = strlen($string); 1757 $depth = 0; 1758 1759 $output = ''; 1760 1761 while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) { 1762 $output .= substr($string, $position, $pos - $position); 1763 $position = $pos + 1; 1764 if ($string[$pos - 1] !== '\\') { 1765 $depth++; 1766 while ($depth && $position < $length) { 1767 $position += strcspn($string, '()', $position); 1768 if ($string[$position - 1] === '\\') { 1769 $position++; 1770 continue; 1771 } elseif (isset($string[$position])) { 1772 switch ($string[$position]) { 1773 case '(': 1774 $depth++; 1775 break; 1776 1777 case ')': 1778 $depth--; 1779 break; 1780 } 1781 $position++; 1782 } else { 1783 break; 1784 } 1785 } 1786 } else { 1787 $output .= '('; 1788 } 1789 } 1790 $output .= substr($string, $position); 1791 1792 return $output; 1793 } 1794 1795 public static function parse_mime($mime) 1796 { 1797 if (($pos = strpos($mime, ';')) === false) { 1798 return trim($mime); 1799 } 1800 1801 return trim(substr($mime, 0, $pos)); 1802 } 1803 1804 public static function atom_03_construct_type($attribs) 1805 { 1806 if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode'])) === 'base64') { 1807 $mode = \SimplePie\SimplePie::CONSTRUCT_BASE64; 1808 } else { 1809 $mode = \SimplePie\SimplePie::CONSTRUCT_NONE; 1810 } 1811 if (isset($attribs['']['type'])) { 1812 switch (strtolower(trim($attribs['']['type']))) { 1813 case 'text': 1814 case 'text/plain': 1815 return \SimplePie\SimplePie::CONSTRUCT_TEXT | $mode; 1816 1817 case 'html': 1818 case 'text/html': 1819 return \SimplePie\SimplePie::CONSTRUCT_HTML | $mode; 1820 1821 case 'xhtml': 1822 case 'application/xhtml+xml': 1823 return \SimplePie\SimplePie::CONSTRUCT_XHTML | $mode; 1824 1825 default: 1826 return \SimplePie\SimplePie::CONSTRUCT_NONE | $mode; 1827 } 1828 } 1829 1830 return \SimplePie\SimplePie::CONSTRUCT_TEXT | $mode; 1831 } 1832 1833 public static function atom_10_construct_type($attribs) 1834 { 1835 if (isset($attribs['']['type'])) { 1836 switch (strtolower(trim($attribs['']['type']))) { 1837 case 'text': 1838 return \SimplePie\SimplePie::CONSTRUCT_TEXT; 1839 1840 case 'html': 1841 return \SimplePie\SimplePie::CONSTRUCT_HTML; 1842 1843 case 'xhtml': 1844 return \SimplePie\SimplePie::CONSTRUCT_XHTML; 1845 1846 default: 1847 return \SimplePie\SimplePie::CONSTRUCT_NONE; 1848 } 1849 } 1850 return \SimplePie\SimplePie::CONSTRUCT_TEXT; 1851 } 1852 1853 public static function atom_10_content_construct_type($attribs) 1854 { 1855 if (isset($attribs['']['type'])) { 1856 $type = strtolower(trim($attribs['']['type'])); 1857 switch ($type) { 1858 case 'text': 1859 return \SimplePie\SimplePie::CONSTRUCT_TEXT; 1860 1861 case 'html': 1862 return \SimplePie\SimplePie::CONSTRUCT_HTML; 1863 1864 case 'xhtml': 1865 return \SimplePie\SimplePie::CONSTRUCT_XHTML; 1866 } 1867 if (in_array(substr($type, -4), ['+xml', '/xml']) || substr($type, 0, 5) === 'text/') { 1868 return \SimplePie\SimplePie::CONSTRUCT_NONE; 1869 } else { 1870 return \SimplePie\SimplePie::CONSTRUCT_BASE64; 1871 } 1872 } 1873 1874 return \SimplePie\SimplePie::CONSTRUCT_TEXT; 1875 } 1876 1877 public static function is_isegment_nz_nc($string) 1878 { 1879 return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); 1880 } 1881 1882 public static function space_separated_tokens($string) 1883 { 1884 $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; 1885 $string_length = strlen($string); 1886 1887 $position = strspn($string, $space_characters); 1888 $tokens = []; 1889 1890 while ($position < $string_length) { 1891 $len = strcspn($string, $space_characters, $position); 1892 $tokens[] = substr($string, $position, $len); 1893 $position += $len; 1894 $position += strspn($string, $space_characters, $position); 1895 } 1896 1897 return $tokens; 1898 } 1899 1900 /** 1901 * Converts a unicode codepoint to a UTF-8 character 1902 * 1903 * @static 1904 * @param int $codepoint Unicode codepoint 1905 * @return string UTF-8 character 1906 */ 1907 public static function codepoint_to_utf8($codepoint) 1908 { 1909 $codepoint = (int) $codepoint; 1910 if ($codepoint < 0) { 1911 return false; 1912 } elseif ($codepoint <= 0x7f) { 1913 return chr($codepoint); 1914 } elseif ($codepoint <= 0x7ff) { 1915 return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); 1916 } elseif ($codepoint <= 0xffff) { 1917 return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 1918 } elseif ($codepoint <= 0x10ffff) { 1919 return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); 1920 } 1921 1922 // U+FFFD REPLACEMENT CHARACTER 1923 return "\xEF\xBF\xBD"; 1924 } 1925 1926 /** 1927 * Similar to parse_str() 1928 * 1929 * Returns an associative array of name/value pairs, where the value is an 1930 * array of values that have used the same name 1931 * 1932 * @static 1933 * @param string $str The input string. 1934 * @return array 1935 */ 1936 public static function parse_str($str) 1937 { 1938 $return = []; 1939 $str = explode('&', $str); 1940 1941 foreach ($str as $section) { 1942 if (strpos($section, '=') !== false) { 1943 [$name, $value] = explode('=', $section, 2); 1944 $return[urldecode($name)][] = urldecode($value); 1945 } else { 1946 $return[urldecode($section)][] = null; 1947 } 1948 } 1949 1950 return $return; 1951 } 1952 1953 /** 1954 * Detect XML encoding, as per XML 1.0 Appendix F.1 1955 * 1956 * @todo Add support for EBCDIC 1957 * @param string $data XML data 1958 * @param \SimplePie\Registry $registry Class registry 1959 * @return array Possible encodings 1960 */ 1961 public static function xml_encoding($data, $registry) 1962 { 1963 // UTF-32 Big Endian BOM 1964 if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") { 1965 $encoding[] = 'UTF-32BE'; 1966 } 1967 // UTF-32 Little Endian BOM 1968 elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") { 1969 $encoding[] = 'UTF-32LE'; 1970 } 1971 // UTF-16 Big Endian BOM 1972 elseif (substr($data, 0, 2) === "\xFE\xFF") { 1973 $encoding[] = 'UTF-16BE'; 1974 } 1975 // UTF-16 Little Endian BOM 1976 elseif (substr($data, 0, 2) === "\xFF\xFE") { 1977 $encoding[] = 'UTF-16LE'; 1978 } 1979 // UTF-8 BOM 1980 elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") { 1981 $encoding[] = 'UTF-8'; 1982 } 1983 // UTF-32 Big Endian Without BOM 1984 elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") { 1985 if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) { 1986 $parser = $registry->create(Parser::class, [Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')]); 1987 if ($parser->parse()) { 1988 $encoding[] = $parser->encoding; 1989 } 1990 } 1991 $encoding[] = 'UTF-32BE'; 1992 } 1993 // UTF-32 Little Endian Without BOM 1994 elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") { 1995 if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) { 1996 $parser = $registry->create(Parser::class, [Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')]); 1997 if ($parser->parse()) { 1998 $encoding[] = $parser->encoding; 1999 } 2000 } 2001 $encoding[] = 'UTF-32LE'; 2002 } 2003 // UTF-16 Big Endian Without BOM 2004 elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") { 2005 if ($pos = strpos($data, "\x00\x3F\x00\x3E")) { 2006 $parser = $registry->create(Parser::class, [Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')]); 2007 if ($parser->parse()) { 2008 $encoding[] = $parser->encoding; 2009 } 2010 } 2011 $encoding[] = 'UTF-16BE'; 2012 } 2013 // UTF-16 Little Endian Without BOM 2014 elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") { 2015 if ($pos = strpos($data, "\x3F\x00\x3E\x00")) { 2016 $parser = $registry->create(Parser::class, [Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')]); 2017 if ($parser->parse()) { 2018 $encoding[] = $parser->encoding; 2019 } 2020 } 2021 $encoding[] = 'UTF-16LE'; 2022 } 2023 // US-ASCII (or superset) 2024 elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") { 2025 if ($pos = strpos($data, "\x3F\x3E")) { 2026 $parser = $registry->create(Parser::class, [substr($data, 5, $pos - 5)]); 2027 if ($parser->parse()) { 2028 $encoding[] = $parser->encoding; 2029 } 2030 } 2031 $encoding[] = 'UTF-8'; 2032 } 2033 // Fallback to UTF-8 2034 else { 2035 $encoding[] = 'UTF-8'; 2036 } 2037 return $encoding; 2038 } 2039 2040 public static function output_javascript() 2041 { 2042 if (function_exists('ob_gzhandler')) { 2043 ob_start('ob_gzhandler'); 2044 } 2045 header('Content-type: text/javascript; charset: UTF-8'); 2046 header('Cache-Control: must-revalidate'); 2047 header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days 2048 2049 $body = <<<END 2050 function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { 2051 if (placeholder != '') { 2052 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 2053 } 2054 else { 2055 document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>'); 2056 } 2057 } 2058 2059 function embed_flash(bgcolor, width, height, link, loop, type) { 2060 document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>'); 2061 } 2062 2063 function embed_flv(width, height, link, placeholder, loop, player) { 2064 document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>'); 2065 } 2066 2067 function embed_wmedia(width, height, link) { 2068 document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>'); 2069 } 2070 END; 2071 echo $body; 2072 } 2073 2074 /** 2075 * Get the SimplePie build timestamp 2076 * 2077 * Uses the git index if it exists, otherwise uses the modification time 2078 * of the newest file. 2079 */ 2080 public static function get_build() 2081 { 2082 if (static::$SIMPLEPIE_BUILD !== null) { 2083 return static::$SIMPLEPIE_BUILD; 2084 } 2085 2086 $root = dirname(__FILE__, 2); 2087 if (file_exists($root . '/.git/index')) { 2088 static::$SIMPLEPIE_BUILD = filemtime($root . '/.git/index'); 2089 2090 return static::$SIMPLEPIE_BUILD; 2091 } elseif (file_exists($root . '/SimplePie')) { 2092 $time = 0; 2093 foreach (glob($root . '/SimplePie/*.php') as $file) { 2094 if (($mtime = filemtime($file)) > $time) { 2095 $time = $mtime; 2096 } 2097 } 2098 static::$SIMPLEPIE_BUILD = $time; 2099 2100 return static::$SIMPLEPIE_BUILD; 2101 } elseif (file_exists(dirname(__FILE__) . '/Core.php')) { 2102 static::$SIMPLEPIE_BUILD = filemtime(dirname(__FILE__) . '/Core.php'); 2103 2104 return static::$SIMPLEPIE_BUILD; 2105 } 2106 2107 static::$SIMPLEPIE_BUILD = filemtime(__FILE__); 2108 2109 return static::$SIMPLEPIE_BUILD; 2110 } 2111 2112 /** 2113 * Get the default user agent string 2114 * 2115 * @return string 2116 */ 2117 public static function get_default_useragent() 2118 { 2119 return \SimplePie\SimplePie::NAME . '/' . \SimplePie\SimplePie::VERSION . ' (Feed Parser; ' . \SimplePie\SimplePie::URL . '; Allow like Gecko) Build/' . static::get_build(); 2120 } 2121 2122 /** 2123 * Format debugging information 2124 */ 2125 public static function debug(&$sp) 2126 { 2127 $info = 'SimplePie ' . \SimplePie\SimplePie::VERSION . ' Build ' . static::get_build() . "\n"; 2128 $info .= 'PHP ' . PHP_VERSION . "\n"; 2129 if ($sp->error() !== null) { 2130 $info .= 'Error occurred: ' . $sp->error() . "\n"; 2131 } else { 2132 $info .= "No error found.\n"; 2133 } 2134 $info .= "Extensions:\n"; 2135 $extensions = ['pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml']; 2136 foreach ($extensions as $ext) { 2137 if (extension_loaded($ext)) { 2138 $info .= " $ext loaded\n"; 2139 switch ($ext) { 2140 case 'pcre': 2141 $info .= ' Version ' . PCRE_VERSION . "\n"; 2142 break; 2143 case 'curl': 2144 $version = curl_version(); 2145 $info .= ' Version ' . $version['version'] . "\n"; 2146 break; 2147 case 'mbstring': 2148 $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n"; 2149 break; 2150 case 'iconv': 2151 $info .= ' Version ' . ICONV_VERSION . "\n"; 2152 break; 2153 case 'xml': 2154 $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n"; 2155 break; 2156 } 2157 } else { 2158 $info .= " $ext not loaded\n"; 2159 } 2160 } 2161 return $info; 2162 } 2163 2164 public static function silence_errors($num, $str) 2165 { 2166 // No-op 2167 } 2168 2169 /** 2170 * Sanitize a URL by removing HTTP credentials. 2171 * @param string $url the URL to sanitize. 2172 * @return string the same URL without HTTP credentials. 2173 */ 2174 public static function url_remove_credentials($url) 2175 { 2176 return preg_replace('#^(https?://)[^/:@]+:[^/:@]+@#i', '$1', $url); 2177 } 2178 } 2179 2180 class_alias('SimplePie\Misc', 'SimplePie_Misc', false);
title
Description
Body
title
Description
Body
title
Description
Body
title
Body