]> granicus.if.org Git - php/commit
- Revamp of the decoding portion of html.c.
authorGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 10 Oct 2010 19:04:59 +0000 (19:04 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 10 Oct 2010 19:04:59 +0000 (19:04 +0000)
commit7aa43a8d834e386a1b38490644983c0c3587dcd5
tree7c6ec23ac08818bd24463bf3dae8bbb873904d60
parentb1d5cf7348105cb8205b0fe7c54494b1fefd80cf
- Revamp of the decoding portion of html.c.
- Dramatic improvements on the performance of html_entity_decode and htmlspecialchars_decode, as the
  string is now traversed only once. Speedups of 20 to 25 times with Windows release builds and a
  ~250 characters string (for 2nd and subsequent calls).
- Consistent behavior on html_entity_decode. For instance, the entity in "&&lt;" would be decoded,
  but not "&&#233;". Not anymore. The code path for "basic" and non-basic entities is now mostly
  shared.
- Code of html_entity_decode and htmlspecialchars_decode is now shared.
- [DOC] More consistent behavior of htmlspecialchars_decode. Instead of translating only &lt;, &gt;,
  &amp;, &quot;, &#039; and &#39;, now e.g. &#34;, &apos;, &#0039;, &#x27;, etc. are also decoded.
- [DOC] Previous translation of unicode code points in numerical entities was seriously broken. When
  the code points for some character were not the same in unicode and the target encoding, the
  behavior could be an erroneous translation (e.g. 0x80-0xA0 in win-1252) or no translation at all.
  Added unicode translation tables for all single-byte encodings. Entities are not translated for
  multi-byte entities, except for ASCII characters whose code points are shared. We could add
  the huge translation tables (several thousand elements) for those encodings in the future.
- Fixed numerical entities that after # had text accepted by strcol being accepted.
- Much more commented and well-structured code...
- Tests for get_html_translation_table()) are broken. I stared fixing the tests, but then I realized
  it was completely helpless because get_html_translation_table() is broken by not handling
  multi-byte characters correctly.
13 files changed:
ext/standard/basic_functions.c
ext/standard/basic_functions.h
ext/standard/html.c
ext/standard/html_tables.h [new file with mode: 0644]
ext/standard/tests/strings/get_html_translation_table_basic1.phpt
ext/standard/tests/strings/html_entity_decode_cp866.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_iso8859-15.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_iso8859-5.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_koi8-r.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_macroman.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_win1251.phpt [new file with mode: 0644]
ext/standard/tests/strings/html_entity_decode_win1252.phpt [new file with mode: 0644]
ext/standard/tests/strings/htmlentities17.phpt