- Added a 3rd parameter to get_html_translation_table. It now takes a charset

hint, like htmlentities et al.
- Fixed bug #49407 (get_html_translation_table doesn't handle UTF-8).
- Fixed bug #25927 (get_html_translation_table calls the ' ' instead of
  ').
- Fixed tests for get_html_translation_table and unified the Windows and
  non-Windows versions of the tests.
This commit is contained in:
Gustavo André dos Santos Lopes 2010-10-12 02:51:11 +00:00
parent 40c3aefafb
commit 99b613cbc8
13 changed files with 1848 additions and 3548 deletions

5
NEWS
View File

@ -15,6 +15,8 @@
- Implemented FR #50692, not uploaded files don't count towards
max_file_uploads limit. As a side improvement, temporary files are not opened
for empty uploads and, in debug mode, 0-length uploads. (Gustavo)
- Added a 3rd parameter to get_html_translation_table. It now takes a charset
hint, like htmlentities et al. (Gustavo)
- Fixed possible flaw in open_basedir (CVE-2010-3436). (Pierre)
- Fixed MOPS-2010-24, fix string validation. (CVE-2010-2950). (Pierre)
@ -128,12 +130,15 @@
other platforms). (Pierre)
- Fixed bug #50345 (nanosleep not detected properly on some solaris versions).
(Ulf, Tony)
- Fixed bug #49407 (get_html_translation_table doesn't handle UTF-8). (Gustavo)
- Fixed bug #49215 (make fails on glob_wrapper). (Felipe)
- Fixed bug #48831 (php -i has different output to php --ini). (Richard,
Pierre)
- Fixed bug #45921 (Can't initialize character set hebrew). (Andrey)
- Fixed bug #44248 (RFC2616 transgression while HTTPS request through proxy
with SoapClient object). (Dmitry)
- Fixed bug #25927 (get_html_translation_table calls the ' ' instead of
'). (Gustavo)
22 Jul 2010, PHP 5.3.3
- Upgraded bundled sqlite to version 3.6.23.1. (Ilia)

View File

@ -867,7 +867,7 @@ det_charset:
/* }}} */
/* {{{ php_utf32_utf8 */
size_t php_utf32_utf8(unsigned char *buf, int k)
size_t php_utf32_utf8(unsigned char *buf, unsigned k)
{
size_t retval = 0;
@ -1408,54 +1408,86 @@ PHP_FUNCTION(htmlentities)
}
/* }}} */
/* {{{ proto array get_html_translation_table([int table [, int quote_style]])
/* {{{ proto array get_html_translation_table([int table [, int quote_style [, string charset_hint]]])
Returns the internal translation table used by htmlspecialchars and htmlentities */
PHP_FUNCTION(get_html_translation_table)
{
long which = HTML_SPECIALCHARS, quote_style = ENT_COMPAT;
int i, j;
char ind[2];
enum entity_charset charset = determine_charset(NULL TSRMLS_CC);
unsigned int i;
int j;
unsigned char ind[5]; /* max # of 8-bit code units (4; for UTF-8) + 1 for \0 */
void *dummy;
char *charset_hint = NULL;
int charset_hint_len;
enum entity_charset charset;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ll", &which, &quote_style) == FAILURE) {
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lls",
&which, &quote_style, &charset_hint, &charset_hint_len) == FAILURE) {
return;
}
charset = determine_charset(charset_hint TSRMLS_CC);
array_init(return_value);
ind[1] = 0;
switch (which) {
case HTML_ENTITIES:
for (j=0; entity_map[j].charset != cs_terminator; j++) {
if (entity_map[j].charset != charset)
case HTML_ENTITIES:
for (j = 0; entity_map[j].charset != cs_terminator; j++) {
if (entity_map[j].charset != charset)
continue;
for (i = 0; i <= entity_map[j].endchar - entity_map[j].basechar; i++) {
char buffer[16];
unsigned k;
size_t written;
if (entity_map[j].table[i] == NULL)
continue;
for (i = 0; i <= entity_map[j].endchar - entity_map[j].basechar; i++) {
char buffer[16];
k = i + entity_map[j].basechar;
if (entity_map[j].table[i] == NULL)
continue;
/* what about wide chars here ?? */
ind[0] = i + entity_map[j].basechar;
snprintf(buffer, sizeof(buffer), "&%s;", entity_map[j].table[i]);
add_assoc_string(return_value, ind, buffer, 1);
switch (charset) {
case cs_utf_8:
written = php_utf32_utf8(ind, k);
ind[written] = '\0';
break;
case cs_big5:
case cs_gb2312:
case cs_big5hkscs:
case cs_sjis:
/* we have no mappings for these, but if we had... */
/* break through */
default: /* one byte */
written = 1;
ind[0] = (unsigned char)k;
ind[1] = '\0';
break;
}
snprintf(buffer, sizeof(buffer), "&%s;", entity_map[j].table[i]);
if (zend_hash_find(Z_ARRVAL_P(return_value), (const char*)ind, written+1, &dummy) == FAILURE) {
/* in case of the single quote, which is repeated, the first one wins,
* so don't replace the existint mapping */
add_assoc_string(return_value, (const char*)ind, buffer, 1);
}
}
/* break thru */
}
/* break thru */
case HTML_SPECIALCHARS:
for (j = 0; basic_entities[j].charcode != 0; j++) {
if (basic_entities[j].flags && (quote_style & basic_entities[j].flags) == 0)
continue;
case HTML_SPECIALCHARS:
add_assoc_stringl(return_value, "&", "&amp;", sizeof("&amp;") - 1, 1);
for (j = 0; basic_entities[j].charcode != 0; j++) {
if (basic_entities[j].flags && (quote_style & basic_entities[j].flags) == 0)
continue;
ind[0] = (unsigned char)basic_entities[j].charcode;
add_assoc_stringl(return_value, ind, basic_entities[j].entity, basic_entities[j].entitylen, 1);
ind[0] = (unsigned char)basic_entities[j].charcode;
ind[1] = '\0';
if (zend_hash_find(Z_ARRVAL_P(return_value), (const char*)ind, 2, &dummy) == FAILURE) {
add_assoc_stringl(return_value, ind, basic_entities[j].entity,
basic_entities[j].entitylen, 1);
}
add_assoc_stringl(return_value, "&", "&amp;", sizeof("&amp;") - 1, 1);
}
break;
break;
}
}
/* }}} */

View File

@ -1,269 +1,545 @@
--TEST--
Test get_html_translation_table() function : basic functionality - with default args
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == 'WIN'){
die('skip Not for Windows');
}
if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
die('skip failed to set locale settings to "en-US.UTF-8"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
//set locale to en_US.UTF-8
setlocale(LC_ALL, "en_US.UTF-8");
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
// Calling get_html_translation_table() with default arguments
echo "-- with default arguments --\n";
var_dump( get_html_translation_table() );
// Calling get_html_translation_table() with all possible optional arguments
echo "-- with table = HTML_ENTITIES --\n";
$table = HTML_ENTITIES;
var_dump( get_html_translation_table($table) );
var_dump( get_html_translation_table($table, ENT_COMPAT, "UTF-8") );
echo "-- with table = HTML_SPECIALCHARS --\n";
$table = HTML_SPECIALCHARS;
var_dump( get_html_translation_table($table) );
var_dump( get_html_translation_table($table, ENT_COMPAT, "UTF-8") );
echo "Done\n";
?>
--EXPECTF--
*** Testing get_html_translation_table() : basic functionality ***
-- with default arguments --
array(4) {
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_ENTITIES --
array(100) {
[" "]=>
array(252) {
[" "]=>
string(6) "&nbsp;"
["¡"]=>
["¡"]=>
string(7) "&iexcl;"
["¢"]=>
["¢"]=>
string(6) "&cent;"
["£"]=>
["£"]=>
string(7) "&pound;"
["¤"]=>
["¤"]=>
string(8) "&curren;"
["¥"]=>
["¥"]=>
string(5) "&yen;"
["¦"]=>
["¦"]=>
string(8) "&brvbar;"
["§"]=>
["§"]=>
string(6) "&sect;"
["¨"]=>
["¨"]=>
string(5) "&uml;"
["©"]=>
["©"]=>
string(6) "&copy;"
["ª"]=>
["ª"]=>
string(6) "&ordf;"
["«"]=>
["«"]=>
string(7) "&laquo;"
["¬"]=>
["¬"]=>
string(5) "&not;"
["­"]=>
["­"]=>
string(5) "&shy;"
["®"]=>
["®"]=>
string(5) "&reg;"
["¯"]=>
["¯"]=>
string(6) "&macr;"
["°"]=>
["°"]=>
string(5) "&deg;"
["±"]=>
["±"]=>
string(8) "&plusmn;"
["²"]=>
["²"]=>
string(6) "&sup2;"
["³"]=>
["³"]=>
string(6) "&sup3;"
["´"]=>
["´"]=>
string(7) "&acute;"
["µ"]=>
["µ"]=>
string(7) "&micro;"
["¶"]=>
["¶"]=>
string(6) "&para;"
["·"]=>
["·"]=>
string(8) "&middot;"
["¸"]=>
["¸"]=>
string(7) "&cedil;"
["¹"]=>
["¹"]=>
string(6) "&sup1;"
["º"]=>
["º"]=>
string(6) "&ordm;"
["»"]=>
["»"]=>
string(7) "&raquo;"
["¼"]=>
["¼"]=>
string(8) "&frac14;"
["½"]=>
["½"]=>
string(8) "&frac12;"
["¾"]=>
["¾"]=>
string(8) "&frac34;"
["¿"]=>
["¿"]=>
string(8) "&iquest;"
["À"]=>
["À"]=>
string(8) "&Agrave;"
["Á"]=>
["Á"]=>
string(8) "&Aacute;"
["Â"]=>
["Â"]=>
string(7) "&Acirc;"
["Ã"]=>
["Ã"]=>
string(8) "&Atilde;"
["Ä"]=>
["Ä"]=>
string(6) "&Auml;"
["Å"]=>
["Å"]=>
string(7) "&Aring;"
["Æ"]=>
["Æ"]=>
string(7) "&AElig;"
["Ç"]=>
["Ç"]=>
string(8) "&Ccedil;"
["È"]=>
["È"]=>
string(8) "&Egrave;"
["É"]=>
["É"]=>
string(8) "&Eacute;"
["Ê"]=>
["Ê"]=>
string(7) "&Ecirc;"
["Ë"]=>
["Ë"]=>
string(6) "&Euml;"
["Ì"]=>
["Ì"]=>
string(8) "&Igrave;"
["Í"]=>
["Í"]=>
string(8) "&Iacute;"
["Î"]=>
["Î"]=>
string(7) "&Icirc;"
["Ï"]=>
["Ï"]=>
string(6) "&Iuml;"
["Ð"]=>
["Ð"]=>
string(5) "&ETH;"
["Ñ"]=>
["Ñ"]=>
string(8) "&Ntilde;"
["Ò"]=>
["Ò"]=>
string(8) "&Ograve;"
["Ó"]=>
["Ó"]=>
string(8) "&Oacute;"
["Ô"]=>
["Ô"]=>
string(7) "&Ocirc;"
["Õ"]=>
["Õ"]=>
string(8) "&Otilde;"
["Ö"]=>
["Ö"]=>
string(6) "&Ouml;"
["×"]=>
["×"]=>
string(7) "&times;"
["Ø"]=>
["Ø"]=>
string(8) "&Oslash;"
["Ù"]=>
["Ù"]=>
string(8) "&Ugrave;"
["Ú"]=>
["Ú"]=>
string(8) "&Uacute;"
["Û"]=>
["Û"]=>
string(7) "&Ucirc;"
["Ü"]=>
["Ü"]=>
string(6) "&Uuml;"
["Ý"]=>
["Ý"]=>
string(8) "&Yacute;"
["Þ"]=>
["Þ"]=>
string(7) "&THORN;"
["ß"]=>
["ß"]=>
string(7) "&szlig;"
["à"]=>
["à"]=>
string(8) "&agrave;"
["á"]=>
["á"]=>
string(8) "&aacute;"
["â"]=>
["â"]=>
string(7) "&acirc;"
["ã"]=>
["ã"]=>
string(8) "&atilde;"
["ä"]=>
["ä"]=>
string(6) "&auml;"
["å"]=>
["å"]=>
string(7) "&aring;"
["æ"]=>
["æ"]=>
string(7) "&aelig;"
["ç"]=>
["ç"]=>
string(8) "&ccedil;"
["è"]=>
["è"]=>
string(8) "&egrave;"
["é"]=>
["é"]=>
string(8) "&eacute;"
["ê"]=>
["ê"]=>
string(7) "&ecirc;"
["ë"]=>
["ë"]=>
string(6) "&euml;"
["ì"]=>
["ì"]=>
string(8) "&igrave;"
["í"]=>
["í"]=>
string(8) "&iacute;"
["î"]=>
["î"]=>
string(7) "&icirc;"
["ï"]=>
["ï"]=>
string(6) "&iuml;"
["ð"]=>
["ð"]=>
string(5) "&eth;"
["ñ"]=>
["ñ"]=>
string(8) "&ntilde;"
["ò"]=>
["ò"]=>
string(8) "&ograve;"
["ó"]=>
["ó"]=>
string(8) "&oacute;"
["ô"]=>
["ô"]=>
string(7) "&ocirc;"
["õ"]=>
["õ"]=>
string(8) "&otilde;"
["ö"]=>
["ö"]=>
string(6) "&ouml;"
["÷"]=>
["÷"]=>
string(8) "&divide;"
["ø"]=>
["ø"]=>
string(8) "&oslash;"
["ù"]=>
["ù"]=>
string(8) "&ugrave;"
["ú"]=>
["ú"]=>
string(8) "&uacute;"
["û"]=>
["û"]=>
string(7) "&ucirc;"
["ü"]=>
["ü"]=>
string(6) "&uuml;"
["ý"]=>
["ý"]=>
string(8) "&yacute;"
["þ"]=>
["þ"]=>
string(7) "&thorn;"
["ÿ"]=>
["ÿ"]=>
string(6) "&yuml;"
["Œ"]=>
string(7) "&OElig;"
["œ"]=>
string(7) "&oelig;"
["Š"]=>
string(8) "&Scaron;"
["š"]=>
string(8) "&scaron;"
["Ÿ"]=>
string(6) "&Yuml;"
["ƒ"]=>
string(6) "&fnof;"
["ˆ"]=>
string(6) "&circ;"
["˜"]=>
string(7) "&tilde;"
["Α"]=>
string(7) "&Alpha;"
["Β"]=>
string(6) "&Beta;"
["Γ"]=>
string(7) "&Gamma;"
["Δ"]=>
string(7) "&Delta;"
["Ε"]=>
string(9) "&Epsilon;"
["Ζ"]=>
string(6) "&Zeta;"
["Η"]=>
string(5) "&Eta;"
["Θ"]=>
string(7) "&Theta;"
["Ι"]=>
string(6) "&Iota;"
["Κ"]=>
string(7) "&Kappa;"
["Λ"]=>
string(8) "&Lambda;"
["Μ"]=>
string(4) "&Mu;"
["Ν"]=>
string(4) "&Nu;"
["Ξ"]=>
string(4) "&Xi;"
["Ο"]=>
string(9) "&Omicron;"
["Π"]=>
string(4) "&Pi;"
["Ρ"]=>
string(5) "&Rho;"
["Σ"]=>
string(7) "&Sigma;"
["Τ"]=>
string(5) "&Tau;"
["Υ"]=>
string(9) "&Upsilon;"
["Φ"]=>
string(5) "&Phi;"
["Χ"]=>
string(5) "&Chi;"
["Ψ"]=>
string(5) "&Psi;"
["Ω"]=>
string(7) "&Omega;"
["α"]=>
string(7) "&alpha;"
["β"]=>
string(6) "&beta;"
["γ"]=>
string(7) "&gamma;"
["δ"]=>
string(7) "&delta;"
["ε"]=>
string(9) "&epsilon;"
["ζ"]=>
string(6) "&zeta;"
["η"]=>
string(5) "&eta;"
["θ"]=>
string(7) "&theta;"
["ι"]=>
string(6) "&iota;"
["κ"]=>
string(7) "&kappa;"
["λ"]=>
string(8) "&lambda;"
["μ"]=>
string(4) "&mu;"
["ν"]=>
string(4) "&nu;"
["ξ"]=>
string(4) "&xi;"
["ο"]=>
string(9) "&omicron;"
["π"]=>
string(4) "&pi;"
["ρ"]=>
string(5) "&rho;"
["ς"]=>
string(8) "&sigmaf;"
["σ"]=>
string(7) "&sigma;"
["τ"]=>
string(5) "&tau;"
["υ"]=>
string(9) "&upsilon;"
["φ"]=>
string(5) "&phi;"
["χ"]=>
string(5) "&chi;"
["ψ"]=>
string(5) "&psi;"
["ω"]=>
string(7) "&omega;"
["ϑ"]=>
string(10) "&thetasym;"
["ϒ"]=>
string(7) "&upsih;"
["ϖ"]=>
string(5) "&piv;"
[""]=>
string(6) "&ensp;"
[""]=>
string(6) "&emsp;"
[""]=>
string(8) "&thinsp;"
[""]=>
string(6) "&zwnj;"
[""]=>
string(5) "&zwj;"
[""]=>
string(5) "&lrm;"
[""]=>
string(5) "&rlm;"
[""]=>
string(7) "&ndash;"
["—"]=>
string(7) "&mdash;"
[""]=>
string(7) "&lsquo;"
[""]=>
string(7) "&rsquo;"
[""]=>
string(7) "&sbquo;"
["“"]=>
string(7) "&ldquo;"
["”"]=>
string(7) "&rdquo;"
["„"]=>
string(7) "&bdquo;"
["†"]=>
string(8) "&dagger;"
["‡"]=>
string(8) "&Dagger;"
["•"]=>
string(6) "&bull;"
["…"]=>
string(8) "&hellip;"
["‰"]=>
string(8) "&permil;"
[""]=>
string(7) "&prime;"
["″"]=>
string(7) "&Prime;"
[""]=>
string(8) "&lsaquo;"
[""]=>
string(8) "&rsaquo;"
["‾"]=>
string(7) "&oline;"
[""]=>
string(7) "&frasl;"
["€"]=>
string(6) "&euro;"
[""]=>
string(7) "&image;"
["℘"]=>
string(8) "&weierp;"
[""]=>
string(6) "&real;"
["™"]=>
string(7) "&trade;"
["ℵ"]=>
string(9) "&alefsym;"
["←"]=>
string(6) "&larr;"
["↑"]=>
string(6) "&uarr;"
["→"]=>
string(6) "&rarr;"
["↓"]=>
string(6) "&darr;"
["↔"]=>
string(6) "&harr;"
["↵"]=>
string(7) "&crarr;"
["⇐"]=>
string(6) "&lArr;"
["⇑"]=>
string(6) "&uArr;"
["⇒"]=>
string(6) "&rArr;"
["⇓"]=>
string(6) "&dArr;"
["⇔"]=>
string(6) "&hArr;"
["∀"]=>
string(8) "&forall;"
["∂"]=>
string(6) "&part;"
["∃"]=>
string(7) "&exist;"
["∅"]=>
string(7) "&empty;"
["∇"]=>
string(7) "&nabla;"
["∈"]=>
string(6) "&isin;"
["∉"]=>
string(7) "&notin;"
["∋"]=>
string(4) "&ni;"
["∏"]=>
string(6) "&prod;"
["∑"]=>
string(5) "&sum;"
[""]=>
string(7) "&minus;"
[""]=>
string(8) "&lowast;"
["√"]=>
string(7) "&radic;"
["∝"]=>
string(6) "&prop;"
["∞"]=>
string(7) "&infin;"
["∠"]=>
string(5) "&ang;"
["∧"]=>
string(5) "&and;"
[""]=>
string(4) "&or;"
["∩"]=>
string(5) "&cap;"
[""]=>
string(5) "&cup;"
["∫"]=>
string(5) "&int;"
["∴"]=>
string(8) "&there4;"
[""]=>
string(5) "&sim;"
["≅"]=>
string(6) "&cong;"
["≈"]=>
string(7) "&asymp;"
["≠"]=>
string(4) "&ne;"
["≡"]=>
string(7) "&equiv;"
["≤"]=>
string(4) "&le;"
["≥"]=>
string(4) "&ge;"
["⊂"]=>
string(5) "&sub;"
["⊃"]=>
string(5) "&sup;"
["⊄"]=>
string(6) "&nsub;"
["⊆"]=>
string(6) "&sube;"
["⊇"]=>
string(6) "&supe;"
["⊕"]=>
string(7) "&oplus;"
["⊗"]=>
string(8) "&otimes;"
["⊥"]=>
string(6) "&perp;"
["⋅"]=>
string(6) "&sdot;"
["⌈"]=>
string(7) "&lceil;"
["⌉"]=>
string(7) "&rceil;"
["⌊"]=>
string(8) "&lfloor;"
["⌋"]=>
string(8) "&rfloor;"
["〈"]=>
string(6) "&lang;"
["〉"]=>
string(6) "&rang;"
["◊"]=>
string(5) "&loz;"
["♠"]=>
string(8) "&spades;"
["♣"]=>
string(7) "&clubs;"
["♥"]=>
string(8) "&hearts;"
["♦"]=>
string(7) "&diams;"
["&"]=>
string(5) "&amp;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS --
array(4) {
["&"]=>
string(5) "&amp;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -1,673 +0,0 @@
--TEST--
Test get_html_translation_table() function : basic functionality - table as HTML_ENTITIES & diff quote_style
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN"){
die('skip only for Windows');
}
if( !setlocale(LC_ALL, "English_United States.1252") ) {
die('skip failed to set locale settings to "English_United States.1252"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
//set locale
setlocale(LC_ALL, "English_United States.1252");
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
// Calling get_html_translation_table() with default arguments
echo "-- with default arguments --\n";
var_dump( get_html_translation_table() );
// Calling get_html_translation_table() with all arguments
// $table as HTML_ENTITIES and different quote style
echo "-- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --\n";
$table = HTML_ENTITIES;
$quote_style = ENT_COMPAT;
var_dump( get_html_translation_table($table, $quote_style) );
echo "-- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --\n";
$quote_style = ENT_QUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
echo "-- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --\n";
$quote_style = ENT_NOQUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
echo "Done\n";
?>
--EXPECTF--
*** Testing get_html_translation_table() : basic functionality ***
-- with default arguments --
array(4) {
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_ENTITIES & quote_style = ENT_COMPAT --
array(100) {
[" "]=>
string(6) "&nbsp;"
["¡"]=>
string(7) "&iexcl;"
["¢"]=>
string(6) "&cent;"
["£"]=>
string(7) "&pound;"
["¤"]=>
string(8) "&curren;"
["¥"]=>
string(5) "&yen;"
["¦"]=>
string(8) "&brvbar;"
["§"]=>
string(6) "&sect;"
["¨"]=>
string(5) "&uml;"
["©"]=>
string(6) "&copy;"
["ª"]=>
string(6) "&ordf;"
["«"]=>
string(7) "&laquo;"
["¬"]=>
string(5) "&not;"
["­"]=>
string(5) "&shy;"
["®"]=>
string(5) "&reg;"
["¯"]=>
string(6) "&macr;"
["°"]=>
string(5) "&deg;"
["±"]=>
string(8) "&plusmn;"
["²"]=>
string(6) "&sup2;"
["³"]=>
string(6) "&sup3;"
["´"]=>
string(7) "&acute;"
["µ"]=>
string(7) "&micro;"
["¶"]=>
string(6) "&para;"
["·"]=>
string(8) "&middot;"
["¸"]=>
string(7) "&cedil;"
["¹"]=>
string(6) "&sup1;"
["º"]=>
string(6) "&ordm;"
["»"]=>
string(7) "&raquo;"
["¼"]=>
string(8) "&frac14;"
["½"]=>
string(8) "&frac12;"
["¾"]=>
string(8) "&frac34;"
["¿"]=>
string(8) "&iquest;"
["À"]=>
string(8) "&Agrave;"
["Á"]=>
string(8) "&Aacute;"
["Â"]=>
string(7) "&Acirc;"
["Ã"]=>
string(8) "&Atilde;"
["Ä"]=>
string(6) "&Auml;"
["Å"]=>
string(7) "&Aring;"
["Æ"]=>
string(7) "&AElig;"
["Ç"]=>
string(8) "&Ccedil;"
["È"]=>
string(8) "&Egrave;"
["É"]=>
string(8) "&Eacute;"
["Ê"]=>
string(7) "&Ecirc;"
["Ë"]=>
string(6) "&Euml;"
["Ì"]=>
string(8) "&Igrave;"
["Í"]=>
string(8) "&Iacute;"
["Î"]=>
string(7) "&Icirc;"
["Ï"]=>
string(6) "&Iuml;"
["Ð"]=>
string(5) "&ETH;"
["Ñ"]=>
string(8) "&Ntilde;"
["Ò"]=>
string(8) "&Ograve;"
["Ó"]=>
string(8) "&Oacute;"
["Ô"]=>
string(7) "&Ocirc;"
["Õ"]=>
string(8) "&Otilde;"
["Ö"]=>
string(6) "&Ouml;"
["×"]=>
string(7) "&times;"
["Ø"]=>
string(8) "&Oslash;"
["Ù"]=>
string(8) "&Ugrave;"
["Ú"]=>
string(8) "&Uacute;"
["Û"]=>
string(7) "&Ucirc;"
["Ü"]=>
string(6) "&Uuml;"
["Ý"]=>
string(8) "&Yacute;"
["Þ"]=>
string(7) "&THORN;"
["ß"]=>
string(7) "&szlig;"
["à"]=>
string(8) "&agrave;"
["á"]=>
string(8) "&aacute;"
["â"]=>
string(7) "&acirc;"
["ã"]=>
string(8) "&atilde;"
["ä"]=>
string(6) "&auml;"
["å"]=>
string(7) "&aring;"
["æ"]=>
string(7) "&aelig;"
["ç"]=>
string(8) "&ccedil;"
["è"]=>
string(8) "&egrave;"
["é"]=>
string(8) "&eacute;"
["ê"]=>
string(7) "&ecirc;"
["ë"]=>
string(6) "&euml;"
["ì"]=>
string(8) "&igrave;"
["í"]=>
string(8) "&iacute;"
["î"]=>
string(7) "&icirc;"
["ï"]=>
string(6) "&iuml;"
["ð"]=>
string(5) "&eth;"
["ñ"]=>
string(8) "&ntilde;"
["ò"]=>
string(8) "&ograve;"
["ó"]=>
string(8) "&oacute;"
["ô"]=>
string(7) "&ocirc;"
["õ"]=>
string(8) "&otilde;"
["ö"]=>
string(6) "&ouml;"
["÷"]=>
string(8) "&divide;"
["ø"]=>
string(8) "&oslash;"
["ù"]=>
string(8) "&ugrave;"
["ú"]=>
string(8) "&uacute;"
["û"]=>
string(7) "&ucirc;"
["ü"]=>
string(6) "&uuml;"
["ý"]=>
string(8) "&yacute;"
["þ"]=>
string(7) "&thorn;"
["ÿ"]=>
string(6) "&yuml;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_ENTITIES & quote_style = ENT_QUOTES --
array(101) {
[" "]=>
string(6) "&nbsp;"
["¡"]=>
string(7) "&iexcl;"
["¢"]=>
string(6) "&cent;"
["£"]=>
string(7) "&pound;"
["¤"]=>
string(8) "&curren;"
["¥"]=>
string(5) "&yen;"
["¦"]=>
string(8) "&brvbar;"
["§"]=>
string(6) "&sect;"
["¨"]=>
string(5) "&uml;"
["©"]=>
string(6) "&copy;"
["ª"]=>
string(6) "&ordf;"
["«"]=>
string(7) "&laquo;"
["¬"]=>
string(5) "&not;"
["­"]=>
string(5) "&shy;"
["®"]=>
string(5) "&reg;"
["¯"]=>
string(6) "&macr;"
["°"]=>
string(5) "&deg;"
["±"]=>
string(8) "&plusmn;"
["²"]=>
string(6) "&sup2;"
["³"]=>
string(6) "&sup3;"
["´"]=>
string(7) "&acute;"
["µ"]=>
string(7) "&micro;"
["¶"]=>
string(6) "&para;"
["·"]=>
string(8) "&middot;"
["¸"]=>
string(7) "&cedil;"
["¹"]=>
string(6) "&sup1;"
["º"]=>
string(6) "&ordm;"
["»"]=>
string(7) "&raquo;"
["¼"]=>
string(8) "&frac14;"
["½"]=>
string(8) "&frac12;"
["¾"]=>
string(8) "&frac34;"
["¿"]=>
string(8) "&iquest;"
["À"]=>
string(8) "&Agrave;"
["Á"]=>
string(8) "&Aacute;"
["Â"]=>
string(7) "&Acirc;"
["Ã"]=>
string(8) "&Atilde;"
["Ä"]=>
string(6) "&Auml;"
["Å"]=>
string(7) "&Aring;"
["Æ"]=>
string(7) "&AElig;"
["Ç"]=>
string(8) "&Ccedil;"
["È"]=>
string(8) "&Egrave;"
["É"]=>
string(8) "&Eacute;"
["Ê"]=>
string(7) "&Ecirc;"
["Ë"]=>
string(6) "&Euml;"
["Ì"]=>
string(8) "&Igrave;"
["Í"]=>
string(8) "&Iacute;"
["Î"]=>
string(7) "&Icirc;"
["Ï"]=>
string(6) "&Iuml;"
["Ð"]=>
string(5) "&ETH;"
["Ñ"]=>
string(8) "&Ntilde;"
["Ò"]=>
string(8) "&Ograve;"
["Ó"]=>
string(8) "&Oacute;"
["Ô"]=>
string(7) "&Ocirc;"
["Õ"]=>
string(8) "&Otilde;"
["Ö"]=>
string(6) "&Ouml;"
["×"]=>
string(7) "&times;"
["Ø"]=>
string(8) "&Oslash;"
["Ù"]=>
string(8) "&Ugrave;"
["Ú"]=>
string(8) "&Uacute;"
["Û"]=>
string(7) "&Ucirc;"
["Ü"]=>
string(6) "&Uuml;"
["Ý"]=>
string(8) "&Yacute;"
["Þ"]=>
string(7) "&THORN;"
["ß"]=>
string(7) "&szlig;"
["à"]=>
string(8) "&agrave;"
["á"]=>
string(8) "&aacute;"
["â"]=>
string(7) "&acirc;"
["ã"]=>
string(8) "&atilde;"
["ä"]=>
string(6) "&auml;"
["å"]=>
string(7) "&aring;"
["æ"]=>
string(7) "&aelig;"
["ç"]=>
string(8) "&ccedil;"
["è"]=>
string(8) "&egrave;"
["é"]=>
string(8) "&eacute;"
["ê"]=>
string(7) "&ecirc;"
["ë"]=>
string(6) "&euml;"
["ì"]=>
string(8) "&igrave;"
["í"]=>
string(8) "&iacute;"
["î"]=>
string(7) "&icirc;"
["ï"]=>
string(6) "&iuml;"
["ð"]=>
string(5) "&eth;"
["ñ"]=>
string(8) "&ntilde;"
["ò"]=>
string(8) "&ograve;"
["ó"]=>
string(8) "&oacute;"
["ô"]=>
string(7) "&ocirc;"
["õ"]=>
string(8) "&otilde;"
["ö"]=>
string(6) "&ouml;"
["÷"]=>
string(8) "&divide;"
["ø"]=>
string(8) "&oslash;"
["ù"]=>
string(8) "&ugrave;"
["ú"]=>
string(8) "&uacute;"
["û"]=>
string(7) "&ucirc;"
["ü"]=>
string(6) "&uuml;"
["ý"]=>
string(8) "&yacute;"
["þ"]=>
string(7) "&thorn;"
["ÿ"]=>
string(6) "&yuml;"
["""]=>
string(6) "&quot;"
["'"]=>
string(5) "&#39;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_ENTITIES & quote_style = ENT_NOQUOTES --
array(99) {
[" "]=>
string(6) "&nbsp;"
["¡"]=>
string(7) "&iexcl;"
["¢"]=>
string(6) "&cent;"
["£"]=>
string(7) "&pound;"
["¤"]=>
string(8) "&curren;"
["¥"]=>
string(5) "&yen;"
["¦"]=>
string(8) "&brvbar;"
["§"]=>
string(6) "&sect;"
["¨"]=>
string(5) "&uml;"
["©"]=>
string(6) "&copy;"
["ª"]=>
string(6) "&ordf;"
["«"]=>
string(7) "&laquo;"
["¬"]=>
string(5) "&not;"
["­"]=>
string(5) "&shy;"
["®"]=>
string(5) "&reg;"
["¯"]=>
string(6) "&macr;"
["°"]=>
string(5) "&deg;"
["±"]=>
string(8) "&plusmn;"
["²"]=>
string(6) "&sup2;"
["³"]=>
string(6) "&sup3;"
["´"]=>
string(7) "&acute;"
["µ"]=>
string(7) "&micro;"
["¶"]=>
string(6) "&para;"
["·"]=>
string(8) "&middot;"
["¸"]=>
string(7) "&cedil;"
["¹"]=>
string(6) "&sup1;"
["º"]=>
string(6) "&ordm;"
["»"]=>
string(7) "&raquo;"
["¼"]=>
string(8) "&frac14;"
["½"]=>
string(8) "&frac12;"
["¾"]=>
string(8) "&frac34;"
["¿"]=>
string(8) "&iquest;"
["À"]=>
string(8) "&Agrave;"
["Á"]=>
string(8) "&Aacute;"
["Â"]=>
string(7) "&Acirc;"
["Ã"]=>
string(8) "&Atilde;"
["Ä"]=>
string(6) "&Auml;"
["Å"]=>
string(7) "&Aring;"
["Æ"]=>
string(7) "&AElig;"
["Ç"]=>
string(8) "&Ccedil;"
["È"]=>
string(8) "&Egrave;"
["É"]=>
string(8) "&Eacute;"
["Ê"]=>
string(7) "&Ecirc;"
["Ë"]=>
string(6) "&Euml;"
["Ì"]=>
string(8) "&Igrave;"
["Í"]=>
string(8) "&Iacute;"
["Î"]=>
string(7) "&Icirc;"
["Ï"]=>
string(6) "&Iuml;"
["Ð"]=>
string(5) "&ETH;"
["Ñ"]=>
string(8) "&Ntilde;"
["Ò"]=>
string(8) "&Ograve;"
["Ó"]=>
string(8) "&Oacute;"
["Ô"]=>
string(7) "&Ocirc;"
["Õ"]=>
string(8) "&Otilde;"
["Ö"]=>
string(6) "&Ouml;"
["×"]=>
string(7) "&times;"
["Ø"]=>
string(8) "&Oslash;"
["Ù"]=>
string(8) "&Ugrave;"
["Ú"]=>
string(8) "&Uacute;"
["Û"]=>
string(7) "&Ucirc;"
["Ü"]=>
string(6) "&Uuml;"
["Ý"]=>
string(8) "&Yacute;"
["Þ"]=>
string(7) "&THORN;"
["ß"]=>
string(7) "&szlig;"
["à"]=>
string(8) "&agrave;"
["á"]=>
string(8) "&aacute;"
["â"]=>
string(7) "&acirc;"
["ã"]=>
string(8) "&atilde;"
["ä"]=>
string(6) "&auml;"
["å"]=>
string(7) "&aring;"
["æ"]=>
string(7) "&aelig;"
["ç"]=>
string(8) "&ccedil;"
["è"]=>
string(8) "&egrave;"
["é"]=>
string(8) "&eacute;"
["ê"]=>
string(7) "&ecirc;"
["ë"]=>
string(6) "&euml;"
["ì"]=>
string(8) "&igrave;"
["í"]=>
string(8) "&iacute;"
["î"]=>
string(7) "&icirc;"
["ï"]=>
string(6) "&iuml;"
["ð"]=>
string(5) "&eth;"
["ñ"]=>
string(8) "&ntilde;"
["ò"]=>
string(8) "&ograve;"
["ó"]=>
string(8) "&oacute;"
["ô"]=>
string(7) "&ocirc;"
["õ"]=>
string(8) "&otilde;"
["ö"]=>
string(6) "&ouml;"
["÷"]=>
string(8) "&divide;"
["ø"]=>
string(8) "&oslash;"
["ù"]=>
string(8) "&ugrave;"
["ú"]=>
string(8) "&uacute;"
["û"]=>
string(7) "&ucirc;"
["ü"]=>
string(6) "&uuml;"
["ý"]=>
string(8) "&yacute;"
["þ"]=>
string(7) "&thorn;"
["ÿ"]=>
string(6) "&yuml;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -1,79 +0,0 @@
--TEST--
Test get_html_translation_table() function : basic functionality - table as HTML_SPECIALCHARS
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN"){
die('skip only for Windows');
}
if( !setlocale(LC_ALL, "English_United States.1252") ) {
die('skip failed to set locale settings to "English_United States.1252"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/* test get_html_translation_table() when $table argument is specified as HTML_SPECIALCHARS */
//set locale
setlocale(LC_ALL, "English_United States.1252");
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
// $table as HTML_SEPCIALCHARS and different quote style
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --\n";
$table = HTML_SPECIALCHARS;
$quote_style = ENT_COMPAT;
var_dump( get_html_translation_table($table, $quote_style) );
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --\n";
$quote_style = ENT_QUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --\n";
$quote_style = ENT_NOQUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
echo "Done\n";
?>
--EXPECTF--
*** Testing get_html_translation_table() : basic functionality ***
-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --
array(4) {
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --
array(5) {
["""]=>
string(6) "&quot;"
["'"]=>
string(5) "&#39;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -1,42 +1,29 @@
--TEST--
Test get_html_translation_table() function : basic functionality - table as HTML_SPECIALCHARS
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == "WIN"){
die('skip Not for Windows');
}
if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
die('skip failed to set locale settings to "en-US.UTF-8"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/* test get_html_translation_table() when $table argument is specified as HTML_SPECIALCHARS */
//set locale to en_US.UTF-8
setlocale(LC_ALL, "en_US.UTF-8");
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
// $table as HTML_SEPCIALCHARS and different quote style
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --\n";
$table = HTML_SPECIALCHARS;
$quote_style = ENT_COMPAT;
var_dump( get_html_translation_table($table, $quote_style) );
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --\n";
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --\n";
$quote_style = ENT_QUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --\n";
echo "-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --\n";
$quote_style = ENT_NOQUOTES;
var_dump( get_html_translation_table($table, $quote_style) );
var_dump( get_html_translation_table($table, $quote_style, "UTF-8") );
echo "Done\n";
?>
@ -44,35 +31,35 @@ echo "Done\n";
*** Testing get_html_translation_table() : basic functionality ***
-- with table = HTML_SPECIALCHARS & quote_style = ENT_COMPAT --
array(4) {
["&"]=>
string(5) "&amp;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
}
-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTES --
array(5) {
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS & quote_style = ENT_QUOTE --
array(5) {
["""]=>
string(6) "&quot;"
["'"]=>
string(5) "&#39;"
string(6) "&#039;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTE --
-- with table = HTML_SPECIALCHARS & quote_style = ENT_NOQUOTES --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -1,59 +1,79 @@
--TEST--
Test get_html_translation_table() function : basic functionality - with default args
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN"){
die('skip only for Windows');
}
if( !setlocale(LC_ALL, "English_United States.1252") ) {
die('skip failed to set locale settings to "English_United States.1252"');
}
?>
Test get_html_translation_table() function : basic functionality - charset WINDOWS-1252
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/* Test get_html_translation_table() when table is specified as HTML_ENTITIES */
//set locale
setlocale(LC_ALL, "English_United States.1252");
echo "*** Testing get_html_translation_table() : basic functionality/Windows-1252 ***\n";
echo "*** Testing get_html_translation_table() : basic functionality ***\n";
// Calling get_html_translation_table() with default arguments
echo "-- with default arguments --\n";
var_dump( get_html_translation_table() );
// Calling get_html_translation_table() with all possible optional arguments
echo "-- with table = HTML_ENTITIES --\n";
$table = HTML_ENTITIES;
var_dump( get_html_translation_table($table) );
var_dump( get_html_translation_table($table, ENT_COMPAT, "WINDOWS-1252") );
echo "-- with table = HTML_SPECIALCHARS --\n";
$table = HTML_SPECIALCHARS;
var_dump( get_html_translation_table($table) );
var_dump( get_html_translation_table($table, ENT_COMPAT, "WINDOWS-1252") );
echo "Done\n";
?>
--EXPECTF--
*** Testing get_html_translation_table() : basic functionality ***
-- with default arguments --
array(4) {
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
*** Testing get_html_translation_table() : basic functionality/Windows-1252 ***
-- with table = HTML_ENTITIES --
array(100) {
array(125) {
["€"]=>
string(6) "&euro;"
[""]=>
string(7) "&sbquo;"
["ƒ"]=>
string(6) "&fnof;"
["„"]=>
string(7) "&bdquo;"
["…"]=>
string(8) "&hellip;"
["†"]=>
string(8) "&dagger;"
["‡"]=>
string(8) "&Dagger;"
["ˆ"]=>
string(6) "&circ;"
["‰"]=>
string(8) "&permil;"
["Š"]=>
string(8) "&Scaron;"
[""]=>
string(8) "&lsaquo;"
["Œ"]=>
string(7) "&OElig;"
[""]=>
string(7) "&lsquo;"
[""]=>
string(7) "&rsquo;"
["“"]=>
string(7) "&ldquo;"
["”"]=>
string(7) "&rdquo;"
["•"]=>
string(6) "&bull;"
[""]=>
string(7) "&ndash;"
["—"]=>
string(7) "&mdash;"
["˜"]=>
string(7) "&tilde;"
["™"]=>
string(7) "&trade;"
["š"]=>
string(8) "&scaron;"
[""]=>
string(8) "&rsaquo;"
["œ"]=>
string(7) "&oelig;"
["Ÿ"]=>
string(6) "&Yuml;"
[" "]=>
string(6) "&nbsp;"
["¡"]=>
@ -246,24 +266,24 @@ array(100) {
string(7) "&thorn;"
["ÿ"]=>
string(6) "&yuml;"
["&"]=>
string(5) "&amp;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- with table = HTML_SPECIALCHARS --
array(4) {
["&"]=>
string(5) "&amp;"
["""]=>
string(6) "&quot;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -2,7 +2,7 @@
Test get_html_translation_table() function : error conditions
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
@ -15,7 +15,7 @@ $table = HTML_ENTITIES;
$quote_style = ENT_COMPAT;
$extra_arg = 10;
var_dump( get_html_translation_table($table, $quote_style, $extra_arg) );
var_dump( get_html_translation_table($table, $quote_style, "UTF-8", $extra_arg) );
echo "Done\n";
?>
@ -24,6 +24,6 @@ echo "Done\n";
-- Testing get_html_translation_table() function with more than expected no. of arguments --
Warning: get_html_translation_table() expects at most 2 parameters, 3 given in %s on line %d
Warning: get_html_translation_table() expects at most 3 parameters, 4 given in %s on line %d
NULL
Done

View File

@ -1,220 +0,0 @@
--TEST--
Test get_html_translation_table() function : usage variations - unexpected quote_style values
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) != "WIN"){
die('skip only for Windows');
}
if( !setlocale(LC_ALL, "English_United States.1252") ) {
die('skip failed to set locale settings to "English_United States.1252"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
/*
* test get_html_translation_table() with unexpteced value for argument $quote_style
*/
//set locale
setlocale(LC_ALL, "English_United States.1252");
echo "*** Testing get_html_translation_table() : usage variations ***\n";
// initialize all required variables
$table = HTML_SPECIALCHARS;
// get an unset variable
$unset_var = 10;
unset($unset_var);
// a resource var
$fp = fopen(__FILE__, "r");
// array with different values
$values = array (
// array values
array(),
array(0),
array(1),
array(1, 2),
array('color' => 'red', 'item' => 'pen'),
// boolean values
true,
false,
TRUE,
FALSE,
// string values
"string",
'string',
// objects
new stdclass(),
// empty string
"",
'',
// null vlaues
NULL,
null,
// resource var
$fp,
// undefined variable
@$undefined_var,
// unset variable
@$unset_var
);
// loop through each element of the array and check the working of get_html_translation_table()
// when $quote_style arugment is supplied with different values
echo "\n--- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---\n";
$counter = 1;
for($index = 0; $index < count($values); $index ++) {
echo "-- Iteration $counter --\n";
$quote_style = $values [$index];
var_dump( get_html_translation_table($table, $quote_style) );
$counter ++;
}
echo "Done\n";
?>
--EXPECTF--
*** Testing get_html_translation_table() : usage variations ***
--- Testing get_html_translation_table() by supplying different values for 'quote_style' argument ---
-- Iteration 1 --
Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
NULL
-- Iteration 2 --
Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
NULL
-- Iteration 3 --
Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
NULL
-- Iteration 4 --
Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
NULL
-- Iteration 5 --
Warning: get_html_translation_table() expects parameter 2 to be long, array given in %s on line %s
NULL
-- Iteration 6 --
array(4) {
["'"]=>
string(5) "&#39;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 7 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 8 --
array(4) {
["'"]=>
string(5) "&#39;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 9 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 10 --
Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
NULL
-- Iteration 11 --
Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
NULL
-- Iteration 12 --
Warning: get_html_translation_table() expects parameter 2 to be long, object given in %s on line %s
NULL
-- Iteration 13 --
Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
NULL
-- Iteration 14 --
Warning: get_html_translation_table() expects parameter 2 to be long, string given in %s on line %s
NULL
-- Iteration 15 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 16 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 17 --
Warning: get_html_translation_table() expects parameter 2 to be long, resource given in %s on line %s
NULL
-- Iteration 18 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 19 --
array(3) {
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done

View File

@ -1,18 +1,8 @@
--TEST--
Test get_html_translation_table() function : usage variations - unexpected quote_style values
--SKIPIF--
<?php
if( substr(PHP_OS, 0, 3) == "WIN"){
die('skip Not for Windows');
}
if( !setlocale(LC_ALL, "en_US.UTF-8") ) {
die('skip failed to set locale settings to "en-US.UTF-8"');
}
?>
--FILE--
<?php
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style]] )
/* Prototype : array get_html_translation_table ( [int $table [, int $quote_style [, string charset_hint]]] )
* Description: Returns the internal translation table used by htmlspecialchars and htmlentities
* Source code: ext/standard/html.c
*/
@ -118,43 +108,43 @@ Warning: get_html_translation_table() expects parameter 2 to be long, array give
NULL
-- Iteration 6 --
array(4) {
["&"]=>
string(5) "&amp;"
["'"]=>
string(5) "&#39;"
string(6) "&#039;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 7 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 8 --
array(4) {
["&"]=>
string(5) "&amp;"
["'"]=>
string(5) "&#39;"
string(6) "&#039;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 9 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 10 --
@ -178,21 +168,21 @@ Warning: get_html_translation_table() expects parameter 2 to be long, string giv
NULL
-- Iteration 15 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 16 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 17 --
@ -200,20 +190,20 @@ Warning: get_html_translation_table() expects parameter 2 to be long, resource g
NULL
-- Iteration 18 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
-- Iteration 19 --
array(3) {
["&"]=>
string(5) "&amp;"
["<"]=>
string(4) "&lt;"
[">"]=>
string(4) "&gt;"
["&"]=>
string(5) "&amp;"
}
Done