Skip to content

Commit fdcca93

Browse files
bugreportusercmb69
authored andcommitted
Fix #78535: auto_detect_line_endings value not parsed as bool
1 parent 7165183 commit fdcca93

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2019, PHP 7.2.24
44

5+
- Core:
6+
. Fixed bug #78535 (auto_detect_line_endings value not parsed as bool).
7+
(bugreportuser)
8+
59
- Exif:
610
. Fixed bug #78442 ('Illegal component' on exif_read_data since PHP7)
711
(Kalle)

ext/standard/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ PHP_INI_BEGIN()
166166
STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals)
167167
STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateString, from_address, php_file_globals, file_globals)
168168
STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
169-
STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateLong, auto_detect_line_endings, php_file_globals, file_globals)
169+
STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateBool, auto_detect_line_endings, php_file_globals, file_globals)
170170
PHP_INI_END()
171171

172172
PHP_MINIT_FUNCTION(file)

ext/standard/file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
119119
typedef struct {
120120
int pclose_ret;
121121
size_t def_chunk_size;
122-
zend_long auto_detect_line_endings;
122+
zend_bool auto_detect_line_endings;
123123
zend_long default_socket_timeout;
124124
char *user_agent; /* for the http wrapper */
125125
char *from_address; /* for the ftp and http wrappers */

ext/standard/tests/file/auto_detect_line_endings_1.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
auto_detect_line_endings --INI-- bool
3+
--INI--
4+
auto_detect_line_endings=on
5+
--STDIN--
6+
fooBar1fooBar2fooBar3
7+
--FILE--
8+
<?php
9+
10+
var_dump(ini_get("auto_detect_line_endings"));
11+
12+
var_dump(fgets(STDIN));
13+
var_dump(fgets(STDIN));
14+
var_dump(fgets(STDIN));
15+
16+
echo "Done\n";
17+
?>
18+
--EXPECTF--
19+
string(1) "1"
20+
string(8) "fooBar1"
21+
string(8) "fooBar2"
22+
string(8) "fooBar3
23+
"
24+
Done

ext/standard/tests/file/auto_detect_line_endings_2.phpt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
ini_set auto_detect_line_endings bool
3+
--FILE--
4+
<?php
5+
6+
ini_set("auto_detect_line_endings", "on");
7+
var_dump(ini_get("auto_detect_line_endings"));
8+
9+
$filePath = __DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt";
10+
file_put_contents($filePath, "fooBar1\rfooBar2\rfooBar3");
11+
12+
$stdin = fopen($filePath, "r");
13+
var_dump(fgets($stdin));
14+
var_dump(fgets($stdin));
15+
var_dump(fgets($stdin));
16+
17+
echo "Done\n";
18+
?>
19+
--EXPECTF--
20+
string(2) "on"
21+
string(8) "fooBar1"
22+
string(8) "fooBar2"
23+
string(7) "fooBar3"
24+
Done
25+
--CLEAN--
26+
<?php
27+
unlink(__DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt");
28+
?>

0 commit comments

Comments
 (0)