]> granicus.if.org Git - php/commitdiff
Fix #78535: auto_detect_line_endings value not parsed as bool
authorbugreportuser <37939393+bugreportuser@users.noreply.github.com>
Thu, 12 Sep 2019 18:44:08 +0000 (12:44 -0600)
committerChristoph M. Becker <cmbecker69@gmx.de>
Sat, 14 Sep 2019 16:46:09 +0000 (18:46 +0200)
NEWS
ext/standard/file.c
ext/standard/file.h
ext/standard/tests/file/auto_detect_line_endings_1.phpt [new file with mode: 0644]
ext/standard/tests/file/auto_detect_line_endings_2.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 42a5bfc675cb94b4a6e1c414faf1c1386e2fd32a..fff6f1fb1ad25fd4950f60d6fe55c34781f15679 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? 2019, PHP 7.2.24
 
+- Core:
+  . Fixed bug #78535 (auto_detect_line_endings value not parsed as bool).
+    (bugreportuser)
+
 - Exif:
   . Fixed bug #78442 ('Illegal component' on exif_read_data since PHP7)
        (Kalle)
index ff3bef3f030b9ca4b9f0d0fad396ec1a8ba1bea0..fb5ca26298b52299a1c5e29192eec9b38d856d51 100644 (file)
@@ -166,7 +166,7 @@ PHP_INI_BEGIN()
        STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals)
        STD_PHP_INI_ENTRY("from", NULL, PHP_INI_ALL, OnUpdateString, from_address, php_file_globals, file_globals)
        STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals)
-       STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateLong, auto_detect_line_endings, php_file_globals, file_globals)
+       STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateBool, auto_detect_line_endings, php_file_globals, file_globals)
 PHP_INI_END()
 
 PHP_MINIT_FUNCTION(file)
index 54df0936d3f0eb86a8cf4d05e8737e500090bb22..70fbc798f55265abbb144aebfa1c80b652401180 100644 (file)
@@ -119,7 +119,7 @@ php_meta_tags_token php_next_meta_token(php_meta_tags_data *);
 typedef struct {
        int pclose_ret;
        size_t def_chunk_size;
-       zend_long auto_detect_line_endings;
+       zend_bool auto_detect_line_endings;
        zend_long default_socket_timeout;
        char *user_agent; /* for the http wrapper */
        char *from_address; /* for the ftp and http wrappers */
diff --git a/ext/standard/tests/file/auto_detect_line_endings_1.phpt b/ext/standard/tests/file/auto_detect_line_endings_1.phpt
new file mode 100644 (file)
index 0000000..c79082e
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+auto_detect_line_endings --INI-- bool
+--INI--
+auto_detect_line_endings=on
+--STDIN--
+fooBar1\rfooBar2\rfooBar3
+--FILE--
+<?php
+
+var_dump(ini_get("auto_detect_line_endings"));
+
+var_dump(fgets(STDIN));
+var_dump(fgets(STDIN));
+var_dump(fgets(STDIN));
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(1) "1"
+string(8) "fooBar1\r"
+string(8) "fooBar2\r"
+string(8) "fooBar3
+"
+Done
diff --git a/ext/standard/tests/file/auto_detect_line_endings_2.phpt b/ext/standard/tests/file/auto_detect_line_endings_2.phpt
new file mode 100644 (file)
index 0000000..f33a055
--- /dev/null
@@ -0,0 +1,28 @@
+--TEST--
+ini_set auto_detect_line_endings bool
+--FILE--
+<?php
+
+ini_set("auto_detect_line_endings", "on");
+var_dump(ini_get("auto_detect_line_endings"));
+
+$filePath = __DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt";
+file_put_contents($filePath, "fooBar1\rfooBar2\rfooBar3");
+
+$stdin = fopen($filePath, "r");
+var_dump(fgets($stdin));
+var_dump(fgets($stdin));
+var_dump(fgets($stdin));
+
+echo "Done\n";
+?>
+--EXPECTF--
+string(2) "on"
+string(8) "fooBar1\r"
+string(8) "fooBar2\r"
+string(7) "fooBar3"
+Done
+--CLEAN--
+<?php
+unlink(__DIR__ . DIRECTORY_SEPARATOR . "auto_detect_line_endings_2.txt");
+?>