Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 
47
/**
48
 * Decode HTML Entities
49
 *
50
 * This implements HTML5 as of revision 967 (2007-06-28)
51
 *
52
 * @deprecated Use DOMDocument instead!
53
 * @package SimplePie
54
 */
55
class SimplePie_Decode_HTML_Entities
56
{
57
    /**
58
     * Data to be parsed
59
     *
60
     * @access private
61
     * @var string
62
     */
63
    public $data = '';
64
 
65
    /**
66
     * Currently consumed bytes
67
     *
68
     * @access private
69
     * @var string
70
     */
71
    public $consumed = '';
72
 
73
    /**
74
     * Position of the current byte being parsed
75
     *
76
     * @access private
77
     * @var int
78
     */
79
    public $position = 0;
80
 
81
    /**
82
     * Create an instance of the class with the input data
83
     *
84
     * @access public
85
     * @param string $data Input data
86
     */
87
    public function __construct($data)
88
    {
89
        $this->data = $data;
90
    }
91
 
92
    /**
93
     * Parse the input data
94
     *
95
     * @access public
96
     * @return string Output data
97
     */
98
    public function parse()
99
    {
100
        while (($this->position = strpos($this->data, '&', $this->position)) !== false) {
101
            $this->consume();
102
            $this->entity();
103
            $this->consumed = '';
104
        }
105
        return $this->data;
106
    }
107
 
108
    /**
109
     * Consume the next byte
110
     *
111
     * @access private
112
     * @return mixed The next byte, or false, if there is no more data
113
     */
114
    public function consume()
115
    {
116
        if (isset($this->data[$this->position])) {
117
            $this->consumed .= $this->data[$this->position];
118
            return $this->data[$this->position++];
119
        }
120
 
121
        return false;
122
    }
123
 
124
    /**
125
     * Consume a range of characters
126
     *
127
     * @access private
128
     * @param string $chars Characters to consume
129
     * @return mixed A series of characters that match the range, or false
130
     */
131
    public function consume_range($chars)
132
    {
133
        if ($len = strspn($this->data, $chars, $this->position)) {
134
            $data = substr($this->data, $this->position, $len);
135
            $this->consumed .= $data;
136
            $this->position += $len;
137
            return $data;
138
        }
139
 
140
        return false;
141
    }
142
 
143
    /**
144
     * Unconsume one byte
145
     *
146
     * @access private
147
     */
148
    public function unconsume()
149
    {
150
        $this->consumed = substr($this->consumed, 0, -1);
151
        $this->position--;
152
    }
153
 
154
    /**
155
     * Decode an entity
156
     *
157
     * @access private
158
     */
159
    public function entity()
160
    {
161
        switch ($this->consume()) {
162
            case "\x09":
163
            case "\x0A":
164
            case "\x0B":
165
            case "\x0C":
166
            case "\x20":
167
            case "\x3C":
168
            case "\x26":
169
            case false:
170
                break;
171
 
172
            case "\x23":
173
                switch ($this->consume()) {
174
                    case "\x78":
175
                    case "\x58":
176
                        $range = '0123456789ABCDEFabcdef';
177
                        $hex = true;
178
                        break;
179
 
180
                    default:
181
                        $range = '0123456789';
182
                        $hex = false;
183
                        $this->unconsume();
184
                        break;
185
                }
186
 
187
                if ($codepoint = $this->consume_range($range)) {
188
                    static $windows_1252_specials = [0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"];
189
 
190
                    if ($hex) {
191
                        $codepoint = hexdec($codepoint);
192
                    } else {
193
                        $codepoint = intval($codepoint);
194
                    }
195
 
196
                    if (isset($windows_1252_specials[$codepoint])) {
197
                        $replacement = $windows_1252_specials[$codepoint];
198
                    } else {
199
                        $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint);
200
                    }
201
 
202
                    if (!in_array($this->consume(), [';', false], true)) {
203
                        $this->unconsume();
204
                    }
205
 
206
                    $consumed_length = strlen($this->consumed);
207
                    $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length);
208
                    $this->position += strlen($replacement) - $consumed_length;
209
                }
210
                break;
211
 
212
            default:
213
                static $entities = [
214
                    'Aacute' => "\xC3\x81",
215
                    'aacute' => "\xC3\xA1",
216
                    'Aacute;' => "\xC3\x81",
217
                    'aacute;' => "\xC3\xA1",
218
                    'Acirc' => "\xC3\x82",
219
                    'acirc' => "\xC3\xA2",
220
                    'Acirc;' => "\xC3\x82",
221
                    'acirc;' => "\xC3\xA2",
222
                    'acute' => "\xC2\xB4",
223
                    'acute;' => "\xC2\xB4",
224
                    'AElig' => "\xC3\x86",
225
                    'aelig' => "\xC3\xA6",
226
                    'AElig;' => "\xC3\x86",
227
                    'aelig;' => "\xC3\xA6",
228
                    'Agrave' => "\xC3\x80",
229
                    'agrave' => "\xC3\xA0",
230
                    'Agrave;' => "\xC3\x80",
231
                    'agrave;' => "\xC3\xA0",
232
                    'alefsym;' => "\xE2\x84\xB5",
233
                    'Alpha;' => "\xCE\x91",
234
                    'alpha;' => "\xCE\xB1",
235
                    'AMP' => "\x26",
236
                    'amp' => "\x26",
237
                    'AMP;' => "\x26",
238
                    'amp;' => "\x26",
239
                    'and;' => "\xE2\x88\xA7",
240
                    'ang;' => "\xE2\x88\xA0",
241
                    'apos;' => "\x27",
242
                    'Aring' => "\xC3\x85",
243
                    'aring' => "\xC3\xA5",
244
                    'Aring;' => "\xC3\x85",
245
                    'aring;' => "\xC3\xA5",
246
                    'asymp;' => "\xE2\x89\x88",
247
                    'Atilde' => "\xC3\x83",
248
                    'atilde' => "\xC3\xA3",
249
                    'Atilde;' => "\xC3\x83",
250
                    'atilde;' => "\xC3\xA3",
251
                    'Auml' => "\xC3\x84",
252
                    'auml' => "\xC3\xA4",
253
                    'Auml;' => "\xC3\x84",
254
                    'auml;' => "\xC3\xA4",
255
                    'bdquo;' => "\xE2\x80\x9E",
256
                    'Beta;' => "\xCE\x92",
257
                    'beta;' => "\xCE\xB2",
258
                    'brvbar' => "\xC2\xA6",
259
                    'brvbar;' => "\xC2\xA6",
260
                    'bull;' => "\xE2\x80\xA2",
261
                    'cap;' => "\xE2\x88\xA9",
262
                    'Ccedil' => "\xC3\x87",
263
                    'ccedil' => "\xC3\xA7",
264
                    'Ccedil;' => "\xC3\x87",
265
                    'ccedil;' => "\xC3\xA7",
266
                    'cedil' => "\xC2\xB8",
267
                    'cedil;' => "\xC2\xB8",
268
                    'cent' => "\xC2\xA2",
269
                    'cent;' => "\xC2\xA2",
270
                    'Chi;' => "\xCE\xA7",
271
                    'chi;' => "\xCF\x87",
272
                    'circ;' => "\xCB\x86",
273
                    'clubs;' => "\xE2\x99\xA3",
274
                    'cong;' => "\xE2\x89\x85",
275
                    'COPY' => "\xC2\xA9",
276
                    'copy' => "\xC2\xA9",
277
                    'COPY;' => "\xC2\xA9",
278
                    'copy;' => "\xC2\xA9",
279
                    'crarr;' => "\xE2\x86\xB5",
280
                    'cup;' => "\xE2\x88\xAA",
281
                    'curren' => "\xC2\xA4",
282
                    'curren;' => "\xC2\xA4",
283
                    'Dagger;' => "\xE2\x80\xA1",
284
                    'dagger;' => "\xE2\x80\xA0",
285
                    'dArr;' => "\xE2\x87\x93",
286
                    'darr;' => "\xE2\x86\x93",
287
                    'deg' => "\xC2\xB0",
288
                    'deg;' => "\xC2\xB0",
289
                    'Delta;' => "\xCE\x94",
290
                    'delta;' => "\xCE\xB4",
291
                    'diams;' => "\xE2\x99\xA6",
292
                    'divide' => "\xC3\xB7",
293
                    'divide;' => "\xC3\xB7",
294
                    'Eacute' => "\xC3\x89",
295
                    'eacute' => "\xC3\xA9",
296
                    'Eacute;' => "\xC3\x89",
297
                    'eacute;' => "\xC3\xA9",
298
                    'Ecirc' => "\xC3\x8A",
299
                    'ecirc' => "\xC3\xAA",
300
                    'Ecirc;' => "\xC3\x8A",
301
                    'ecirc;' => "\xC3\xAA",
302
                    'Egrave' => "\xC3\x88",
303
                    'egrave' => "\xC3\xA8",
304
                    'Egrave;' => "\xC3\x88",
305
                    'egrave;' => "\xC3\xA8",
306
                    'empty;' => "\xE2\x88\x85",
307
                    'emsp;' => "\xE2\x80\x83",
308
                    'ensp;' => "\xE2\x80\x82",
309
                    'Epsilon;' => "\xCE\x95",
310
                    'epsilon;' => "\xCE\xB5",
311
                    'equiv;' => "\xE2\x89\xA1",
312
                    'Eta;' => "\xCE\x97",
313
                    'eta;' => "\xCE\xB7",
314
                    'ETH' => "\xC3\x90",
315
                    'eth' => "\xC3\xB0",
316
                    'ETH;' => "\xC3\x90",
317
                    'eth;' => "\xC3\xB0",
318
                    'Euml' => "\xC3\x8B",
319
                    'euml' => "\xC3\xAB",
320
                    'Euml;' => "\xC3\x8B",
321
                    'euml;' => "\xC3\xAB",
322
                    'euro;' => "\xE2\x82\xAC",
323
                    'exist;' => "\xE2\x88\x83",
324
                    'fnof;' => "\xC6\x92",
325
                    'forall;' => "\xE2\x88\x80",
326
                    'frac12' => "\xC2\xBD",
327
                    'frac12;' => "\xC2\xBD",
328
                    'frac14' => "\xC2\xBC",
329
                    'frac14;' => "\xC2\xBC",
330
                    'frac34' => "\xC2\xBE",
331
                    'frac34;' => "\xC2\xBE",
332
                    'frasl;' => "\xE2\x81\x84",
333
                    'Gamma;' => "\xCE\x93",
334
                    'gamma;' => "\xCE\xB3",
335
                    'ge;' => "\xE2\x89\xA5",
336
                    'GT' => "\x3E",
337
                    'gt' => "\x3E",
338
                    'GT;' => "\x3E",
339
                    'gt;' => "\x3E",
340
                    'hArr;' => "\xE2\x87\x94",
341
                    'harr;' => "\xE2\x86\x94",
342
                    'hearts;' => "\xE2\x99\xA5",
343
                    'hellip;' => "\xE2\x80\xA6",
344
                    'Iacute' => "\xC3\x8D",
345
                    'iacute' => "\xC3\xAD",
346
                    'Iacute;' => "\xC3\x8D",
347
                    'iacute;' => "\xC3\xAD",
348
                    'Icirc' => "\xC3\x8E",
349
                    'icirc' => "\xC3\xAE",
350
                    'Icirc;' => "\xC3\x8E",
351
                    'icirc;' => "\xC3\xAE",
352
                    'iexcl' => "\xC2\xA1",
353
                    'iexcl;' => "\xC2\xA1",
354
                    'Igrave' => "\xC3\x8C",
355
                    'igrave' => "\xC3\xAC",
356
                    'Igrave;' => "\xC3\x8C",
357
                    'igrave;' => "\xC3\xAC",
358
                    'image;' => "\xE2\x84\x91",
359
                    'infin;' => "\xE2\x88\x9E",
360
                    'int;' => "\xE2\x88\xAB",
361
                    'Iota;' => "\xCE\x99",
362
                    'iota;' => "\xCE\xB9",
363
                    'iquest' => "\xC2\xBF",
364
                    'iquest;' => "\xC2\xBF",
365
                    'isin;' => "\xE2\x88\x88",
366
                    'Iuml' => "\xC3\x8F",
367
                    'iuml' => "\xC3\xAF",
368
                    'Iuml;' => "\xC3\x8F",
369
                    'iuml;' => "\xC3\xAF",
370
                    'Kappa;' => "\xCE\x9A",
371
                    'kappa;' => "\xCE\xBA",
372
                    'Lambda;' => "\xCE\x9B",
373
                    'lambda;' => "\xCE\xBB",
374
                    'lang;' => "\xE3\x80\x88",
375
                    'laquo' => "\xC2\xAB",
376
                    'laquo;' => "\xC2\xAB",
377
                    'lArr;' => "\xE2\x87\x90",
378
                    'larr;' => "\xE2\x86\x90",
379
                    'lceil;' => "\xE2\x8C\x88",
380
                    'ldquo;' => "\xE2\x80\x9C",
381
                    'le;' => "\xE2\x89\xA4",
382
                    'lfloor;' => "\xE2\x8C\x8A",
383
                    'lowast;' => "\xE2\x88\x97",
384
                    'loz;' => "\xE2\x97\x8A",
385
                    'lrm;' => "\xE2\x80\x8E",
386
                    'lsaquo;' => "\xE2\x80\xB9",
387
                    'lsquo;' => "\xE2\x80\x98",
388
                    'LT' => "\x3C",
389
                    'lt' => "\x3C",
390
                    'LT;' => "\x3C",
391
                    'lt;' => "\x3C",
392
                    'macr' => "\xC2\xAF",
393
                    'macr;' => "\xC2\xAF",
394
                    'mdash;' => "\xE2\x80\x94",
395
                    'micro' => "\xC2\xB5",
396
                    'micro;' => "\xC2\xB5",
397
                    'middot' => "\xC2\xB7",
398
                    'middot;' => "\xC2\xB7",
399
                    'minus;' => "\xE2\x88\x92",
400
                    'Mu;' => "\xCE\x9C",
401
                    'mu;' => "\xCE\xBC",
402
                    'nabla;' => "\xE2\x88\x87",
403
                    'nbsp' => "\xC2\xA0",
404
                    'nbsp;' => "\xC2\xA0",
405
                    'ndash;' => "\xE2\x80\x93",
406
                    'ne;' => "\xE2\x89\xA0",
407
                    'ni;' => "\xE2\x88\x8B",
408
                    'not' => "\xC2\xAC",
409
                    'not;' => "\xC2\xAC",
410
                    'notin;' => "\xE2\x88\x89",
411
                    'nsub;' => "\xE2\x8A\x84",
412
                    'Ntilde' => "\xC3\x91",
413
                    'ntilde' => "\xC3\xB1",
414
                    'Ntilde;' => "\xC3\x91",
415
                    'ntilde;' => "\xC3\xB1",
416
                    'Nu;' => "\xCE\x9D",
417
                    'nu;' => "\xCE\xBD",
418
                    'Oacute' => "\xC3\x93",
419
                    'oacute' => "\xC3\xB3",
420
                    'Oacute;' => "\xC3\x93",
421
                    'oacute;' => "\xC3\xB3",
422
                    'Ocirc' => "\xC3\x94",
423
                    'ocirc' => "\xC3\xB4",
424
                    'Ocirc;' => "\xC3\x94",
425
                    'ocirc;' => "\xC3\xB4",
426
                    'OElig;' => "\xC5\x92",
427
                    'oelig;' => "\xC5\x93",
428
                    'Ograve' => "\xC3\x92",
429
                    'ograve' => "\xC3\xB2",
430
                    'Ograve;' => "\xC3\x92",
431
                    'ograve;' => "\xC3\xB2",
432
                    'oline;' => "\xE2\x80\xBE",
433
                    'Omega;' => "\xCE\xA9",
434
                    'omega;' => "\xCF\x89",
435
                    'Omicron;' => "\xCE\x9F",
436
                    'omicron;' => "\xCE\xBF",
437
                    'oplus;' => "\xE2\x8A\x95",
438
                    'or;' => "\xE2\x88\xA8",
439
                    'ordf' => "\xC2\xAA",
440
                    'ordf;' => "\xC2\xAA",
441
                    'ordm' => "\xC2\xBA",
442
                    'ordm;' => "\xC2\xBA",
443
                    'Oslash' => "\xC3\x98",
444
                    'oslash' => "\xC3\xB8",
445
                    'Oslash;' => "\xC3\x98",
446
                    'oslash;' => "\xC3\xB8",
447
                    'Otilde' => "\xC3\x95",
448
                    'otilde' => "\xC3\xB5",
449
                    'Otilde;' => "\xC3\x95",
450
                    'otilde;' => "\xC3\xB5",
451
                    'otimes;' => "\xE2\x8A\x97",
452
                    'Ouml' => "\xC3\x96",
453
                    'ouml' => "\xC3\xB6",
454
                    'Ouml;' => "\xC3\x96",
455
                    'ouml;' => "\xC3\xB6",
456
                    'para' => "\xC2\xB6",
457
                    'para;' => "\xC2\xB6",
458
                    'part;' => "\xE2\x88\x82",
459
                    'permil;' => "\xE2\x80\xB0",
460
                    'perp;' => "\xE2\x8A\xA5",
461
                    'Phi;' => "\xCE\xA6",
462
                    'phi;' => "\xCF\x86",
463
                    'Pi;' => "\xCE\xA0",
464
                    'pi;' => "\xCF\x80",
465
                    'piv;' => "\xCF\x96",
466
                    'plusmn' => "\xC2\xB1",
467
                    'plusmn;' => "\xC2\xB1",
468
                    'pound' => "\xC2\xA3",
469
                    'pound;' => "\xC2\xA3",
470
                    'Prime;' => "\xE2\x80\xB3",
471
                    'prime;' => "\xE2\x80\xB2",
472
                    'prod;' => "\xE2\x88\x8F",
473
                    'prop;' => "\xE2\x88\x9D",
474
                    'Psi;' => "\xCE\xA8",
475
                    'psi;' => "\xCF\x88",
476
                    'QUOT' => "\x22",
477
                    'quot' => "\x22",
478
                    'QUOT;' => "\x22",
479
                    'quot;' => "\x22",
480
                    'radic;' => "\xE2\x88\x9A",
481
                    'rang;' => "\xE3\x80\x89",
482
                    'raquo' => "\xC2\xBB",
483
                    'raquo;' => "\xC2\xBB",
484
                    'rArr;' => "\xE2\x87\x92",
485
                    'rarr;' => "\xE2\x86\x92",
486
                    'rceil;' => "\xE2\x8C\x89",
487
                    'rdquo;' => "\xE2\x80\x9D",
488
                    'real;' => "\xE2\x84\x9C",
489
                    'REG' => "\xC2\xAE",
490
                    'reg' => "\xC2\xAE",
491
                    'REG;' => "\xC2\xAE",
492
                    'reg;' => "\xC2\xAE",
493
                    'rfloor;' => "\xE2\x8C\x8B",
494
                    'Rho;' => "\xCE\xA1",
495
                    'rho;' => "\xCF\x81",
496
                    'rlm;' => "\xE2\x80\x8F",
497
                    'rsaquo;' => "\xE2\x80\xBA",
498
                    'rsquo;' => "\xE2\x80\x99",
499
                    'sbquo;' => "\xE2\x80\x9A",
500
                    'Scaron;' => "\xC5\xA0",
501
                    'scaron;' => "\xC5\xA1",
502
                    'sdot;' => "\xE2\x8B\x85",
503
                    'sect' => "\xC2\xA7",
504
                    'sect;' => "\xC2\xA7",
505
                    'shy' => "\xC2\xAD",
506
                    'shy;' => "\xC2\xAD",
507
                    'Sigma;' => "\xCE\xA3",
508
                    'sigma;' => "\xCF\x83",
509
                    'sigmaf;' => "\xCF\x82",
510
                    'sim;' => "\xE2\x88\xBC",
511
                    'spades;' => "\xE2\x99\xA0",
512
                    'sub;' => "\xE2\x8A\x82",
513
                    'sube;' => "\xE2\x8A\x86",
514
                    'sum;' => "\xE2\x88\x91",
515
                    'sup;' => "\xE2\x8A\x83",
516
                    'sup1' => "\xC2\xB9",
517
                    'sup1;' => "\xC2\xB9",
518
                    'sup2' => "\xC2\xB2",
519
                    'sup2;' => "\xC2\xB2",
520
                    'sup3' => "\xC2\xB3",
521
                    'sup3;' => "\xC2\xB3",
522
                    'supe;' => "\xE2\x8A\x87",
523
                    'szlig' => "\xC3\x9F",
524
                    'szlig;' => "\xC3\x9F",
525
                    'Tau;' => "\xCE\xA4",
526
                    'tau;' => "\xCF\x84",
527
                    'there4;' => "\xE2\x88\xB4",
528
                    'Theta;' => "\xCE\x98",
529
                    'theta;' => "\xCE\xB8",
530
                    'thetasym;' => "\xCF\x91",
531
                    'thinsp;' => "\xE2\x80\x89",
532
                    'THORN' => "\xC3\x9E",
533
                    'thorn' => "\xC3\xBE",
534
                    'THORN;' => "\xC3\x9E",
535
                    'thorn;' => "\xC3\xBE",
536
                    'tilde;' => "\xCB\x9C",
537
                    'times' => "\xC3\x97",
538
                    'times;' => "\xC3\x97",
539
                    'TRADE;' => "\xE2\x84\xA2",
540
                    'trade;' => "\xE2\x84\xA2",
541
                    'Uacute' => "\xC3\x9A",
542
                    'uacute' => "\xC3\xBA",
543
                    'Uacute;' => "\xC3\x9A",
544
                    'uacute;' => "\xC3\xBA",
545
                    'uArr;' => "\xE2\x87\x91",
546
                    'uarr;' => "\xE2\x86\x91",
547
                    'Ucirc' => "\xC3\x9B",
548
                    'ucirc' => "\xC3\xBB",
549
                    'Ucirc;' => "\xC3\x9B",
550
                    'ucirc;' => "\xC3\xBB",
551
                    'Ugrave' => "\xC3\x99",
552
                    'ugrave' => "\xC3\xB9",
553
                    'Ugrave;' => "\xC3\x99",
554
                    'ugrave;' => "\xC3\xB9",
555
                    'uml' => "\xC2\xA8",
556
                    'uml;' => "\xC2\xA8",
557
                    'upsih;' => "\xCF\x92",
558
                    'Upsilon;' => "\xCE\xA5",
559
                    'upsilon;' => "\xCF\x85",
560
                    'Uuml' => "\xC3\x9C",
561
                    'uuml' => "\xC3\xBC",
562
                    'Uuml;' => "\xC3\x9C",
563
                    'uuml;' => "\xC3\xBC",
564
                    'weierp;' => "\xE2\x84\x98",
565
                    'Xi;' => "\xCE\x9E",
566
                    'xi;' => "\xCE\xBE",
567
                    'Yacute' => "\xC3\x9D",
568
                    'yacute' => "\xC3\xBD",
569
                    'Yacute;' => "\xC3\x9D",
570
                    'yacute;' => "\xC3\xBD",
571
                    'yen' => "\xC2\xA5",
572
                    'yen;' => "\xC2\xA5",
573
                    'yuml' => "\xC3\xBF",
574
                    'Yuml;' => "\xC5\xB8",
575
                    'yuml;' => "\xC3\xBF",
576
                    'Zeta;' => "\xCE\x96",
577
                    'zeta;' => "\xCE\xB6",
578
                    'zwj;' => "\xE2\x80\x8D",
579
                    'zwnj;' => "\xE2\x80\x8C"
580
                ];
581
 
582
                for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) {
583
                    $consumed = substr($this->consumed, 1);
584
                    if (isset($entities[$consumed])) {
585
                        $match = $consumed;
586
                    }
587
                }
588
 
589
                if ($match !== null) {
590
                    $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1);
591
                    $this->position += strlen($entities[$match]) - strlen($consumed) - 1;
592
                }
593
                break;
594
        }
595
    }
596
}