mirror of
https://github.com/php/php-src.git
synced 2024-10-01 14:56:10 +00:00
193 lines
3.3 KiB
Plaintext
193 lines
3.3 KiB
Plaintext
|
--TEST--
|
||
|
Test htmlspecialchars_decode() function : usage variations - numerical entities for basic characters
|
||
|
--FILE--
|
||
|
<?php
|
||
|
$tests = array(
|
||
|
""", """, """,
|
||
|
"'", "'", "'",
|
||
|
"&", "&", "<",
|
||
|
">", "<", "<",
|
||
|
"<", ">", ">",
|
||
|
"?"
|
||
|
);
|
||
|
|
||
|
echo "*** HTML 4.01/ENT_QUOTES ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML401);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo "\n*** XHTML 1.0/ENT_QUOTES ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XHTML);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo "\n*** HTML5/ENT_QUOTES ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML5);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo "\n*** XML 1.0/ENT_QUOTES ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XML1);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo "\n*** HTML5/ENT_NOQUOTES ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_NOQUOTES | ENT_HTML5);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
echo "\n*** HTML5/ENT_COMPAT ***\n";
|
||
|
|
||
|
foreach ($tests as $t) {
|
||
|
$dec = htmlspecialchars_decode($t, ENT_COMPAT | ENT_HTML5);
|
||
|
if ($t == $dec) {
|
||
|
echo "$t\tNOT DECODED\n";
|
||
|
} else {
|
||
|
echo "$t\tDECODED\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
echo "\nDone.\n";
|
||
|
?>
|
||
|
--EXPECT--
|
||
|
*** HTML 4.01/ENT_QUOTES ***
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
' NOT DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
*** XHTML 1.0/ENT_QUOTES ***
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
*** HTML5/ENT_QUOTES ***
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
*** XML 1.0/ENT_QUOTES ***
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
' DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
*** HTML5/ENT_NOQUOTES ***
|
||
|
" NOT DECODED
|
||
|
" NOT DECODED
|
||
|
" NOT DECODED
|
||
|
' NOT DECODED
|
||
|
' NOT DECODED
|
||
|
' NOT DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
*** HTML5/ENT_COMPAT ***
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
" DECODED
|
||
|
' NOT DECODED
|
||
|
' NOT DECODED
|
||
|
' NOT DECODED
|
||
|
& DECODED
|
||
|
& DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
< DECODED
|
||
|
> DECODED
|
||
|
> DECODED
|
||
|
? NOT DECODED
|
||
|
|
||
|
Done.
|