1
0
mirror of https://github.com/php/php-src.git synced 2026-04-18 05:21:02 +02:00
Files
archived-php-src/ext/standard/tests/strings/htmlspecialchars_decode_variation3.phpt
Peter Kokot d679f02295 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:33:09 +02:00

100 lines
2.5 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
--TEST--
Test htmlspecialchars_decode() function : usage variations - heredoc strings for 'string' argument
--FILE--
<?php
/* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style])
* Description: Convert special HTML entities back to characters
* Source code: ext/standard/html.c
*/
/*
* testing htmlspecialchars_decode() with various heredoc strings as argument for $string
*/
echo "*** Testing htmlspecialchars_decode() : usage variations ***\n";
// empty heredoc string
$empty_string = <<<EOT
EOT;
// Heredoc string with blank line
$blank_line = <<<EOT
EOT;
// heredoc with multiline string
$multiline_string = <<<EOT
<html>Roy&#039;s height &gt; Sam&#039;s height
13 &lt; 25
1111 &amp; 0000 = 0000
&quot;This is a double quoted string&quot;
EOT;
// heredoc with different whitespaces
$diff_whitespaces = <<<EOT
<html>Roy&#039;s height\r &gt; Sam\t&#039;s height
1111\t\t &amp; 0000\v\v = \f0000
&quot; heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces&quot;
EOT;
// heredoc with numeric values
$numeric_string = <<<EOT
<html>11 &lt; 12. 123 string 4567
&quot;string&quot; 1111\t &amp; 0000\t = 0000\n;
EOT;
// heredoc with quote chars & slash
$quote_char_string = <<<EOT
<html>&lt; This's a string with quotes:
"strings in double quote" &amp;
'strings in single quote' &quot;
this\line is &#039;single quoted&#039; /with\slashes </html>
EOT;
$res_heredoc_strings = array(
//heredoc strings
$empty_string,
$blank_line,
$multiline_string,
$diff_whitespaces,
$numeric_string,
$quote_char_string
);
// loop through $res_heredoc_strings array and check the working on htmlspecialchars_decode()
$count = 1;
for($index =0; $index < count($res_heredoc_strings); $index ++) {
echo "-- Iteration $count --\n";
var_dump( htmlspecialchars_decode($res_heredoc_strings[$index]) );
$count++;
}
echo "Done\n";
?>
--EXPECT--
*** Testing htmlspecialchars_decode() : usage variations ***
-- Iteration 1 --
string(0) ""
-- Iteration 2 --
string(0) ""
-- Iteration 3 --
string(103) "<html>Roy&#039;s height > Sam&#039;s height
13 < 25
1111 & 0000 = 0000
"This is a double quoted string""
-- Iteration 4 --
string(130) "<html>Roy&#039;s height
> Sam &#039;s height
1111 & 0000 = 0000
" heredoc
double quoted string. with different white spaces""
-- Iteration 5 --
string(62) "<html>11 < 12. 123 string 4567
"string" 1111 & 0000 = 0000
;"
-- Iteration 6 --
string(153) "<html>< This's a string with quotes:
"strings in double quote" &
'strings in single quote' "
this\line is &#039;single quoted&#039; /with\slashes </html>"
Done