summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorJani Taskinen <jani@php.net>2007-09-28 02:05:10 +0000
committerJani Taskinen <jani@php.net>2007-09-28 02:05:10 +0000
commit09b6f37f20b239dd021c21a1756629c4a64dc2da (patch)
tree635d42eb3591448faedff41f62ce0fff087ea467 /ext
parent0d3bdf23d24ede05b07d613d030514861ab475e5 (diff)
downloadphp-git-09b6f37f20b239dd021c21a1756629c4a64dc2da.tar.gz
MFH:
- Added ".htaccess" style user-defined php.ini files support for CGI/FastCGI. - Added support for special [PATH=/opt/httpd/www.example.com/] sections in php.ini. All directives set in these sections will not be able to be overridden in user-defined ini-files or during runtime in the specified path. - Improved php.ini handling: . Added better error reporting for syntax errors in php.ini files . Allowed "ini-variables" to be used almost everywhere ini php.ini files . Allowed using alphanumeric/variable indexes in "array" ini options . Fixed get_cfg_var() to be able to return "array" ini options - Fixed bug #27372 (parse error loading browscap.ini at apache startup) - Fixed bug #42069 (parse_ini_file() allows using some non-alpha numeric characters)
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/basic_functions.c168
-rw-r--r--ext/standard/basic_functions.h3
-rw-r--r--ext/standard/browscap.c42
-rw-r--r--ext/standard/tests/file/parse_ini_file.phpt400
-rw-r--r--ext/standard/tests/general_functions/parse_ini_basic.data106
-rw-r--r--ext/standard/tests/general_functions/parse_ini_basic.phpt239
-rw-r--r--ext/standard/tests/general_functions/parse_ini_booleans.data27
-rw-r--r--ext/standard/tests/general_functions/parse_ini_booleans.phpt69
-rw-r--r--ext/standard/tests/general_functions/parse_ini_file.phpt28
9 files changed, 796 insertions, 286 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index ce5c866a4c..358904919a 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -41,6 +41,7 @@
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#include "zend.h"
+#include "zend_ini_scanner.h"
#include "zend_language_scanner.h"
#include <zend_language_parser.h>
@@ -947,8 +948,15 @@ static
ZEND_BEGIN_ARG_INFO_EX(arginfo_parse_ini_file, 0, 0, 1)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, process_sections)
+ ZEND_ARG_INFO(0, scanner_mode)
ZEND_END_ARG_INFO()
+#if ZEND_DEBUG
+static
+ZEND_BEGIN_ARG_INFO(arginfo_dump_config_hash, 0)
+ZEND_END_ARG_INFO()
+#endif
+
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_import_request_variables, 0, 0, 1)
ZEND_ARG_INFO(0, types)
@@ -1405,6 +1413,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_fnmatch, 0, 0, 2)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
#endif
+
static
ZEND_BEGIN_ARG_INFO(arginfo_sys_get_temp_dir, 0)
ZEND_END_ARG_INFO()
@@ -3384,7 +3393,7 @@ const zend_function_entry basic_functions[] = {
PHP_FE(set_magic_quotes_runtime, NULL)
PHP_FE(get_magic_quotes_gpc, NULL)
PHP_FE(get_magic_quotes_runtime, NULL)
-
+
PHP_FE(import_request_variables, arginfo_import_request_variables)
PHP_FE(error_log, arginfo_error_log)
PHP_FE(error_get_last, arginfo_error_get_last)
@@ -3430,6 +3439,9 @@ const zend_function_entry basic_functions[] = {
PHP_FE(connection_status, arginfo_connection_status)
PHP_FE(ignore_user_abort, arginfo_ignore_user_abort)
PHP_FE(parse_ini_file, arginfo_parse_ini_file)
+#if ZEND_DEBUG
+ PHP_FE(dump_config_hash, arginfo_dump_config_hash)
+#endif
PHP_FE(is_uploaded_file, arginfo_is_uploaded_file)
PHP_FE(move_uploaded_file, arginfo_move_uploaded_file)
@@ -3988,6 +4000,9 @@ PHP_MINIT_FUNCTION(basic)
REGISTER_LONG_CONSTANT("INI_SYSTEM", ZEND_INI_SYSTEM, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("INI_ALL", ZEND_INI_ALL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SCANNER_NORMAL", ZEND_INI_SCANNER_NORMAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("INI_SCANNER_RAW", ZEND_INI_SCANNER_RAW, CONST_CS | CONST_PERSISTENT);
+
REGISTER_LONG_CONSTANT("PHP_URL_SCHEME", PHP_URL_SCHEME, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_URL_HOST", PHP_URL_HOST, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_URL_PORT", PHP_URL_PORT, CONST_CS | CONST_PERSISTENT);
@@ -4847,12 +4862,34 @@ PHP_FUNCTION(get_current_user)
}
/* }}} */
-/* {{{ proto string get_cfg_var(string option_name)
+/* {{{ add_config_entry_cb
+ */
+static int add_config_entry_cb(zval *entry, int num_args, va_list args, zend_hash_key *hash_key TSRMLS_DC)
+{
+ zval *retval = (zval *) va_arg(args, int);
+ zval *tmp;
+
+ if (Z_TYPE_P(entry) == IS_STRING) {
+ if (hash_key->nKeyLength > 0) {
+ add_assoc_stringl_ex(retval, hash_key->arKey, hash_key->nKeyLength, Z_STRVAL_P(entry), Z_STRLEN_P(entry), 1);
+ } else {
+ add_index_stringl(retval, hash_key->h, Z_STRVAL_P(entry), Z_STRLEN_P(entry), 1);
+ }
+ } else if (Z_TYPE_P(entry) == IS_ARRAY) {
+ MAKE_STD_ZVAL(tmp);
+ array_init(tmp);
+ zend_hash_apply_with_arguments(Z_ARRVAL_P(entry), (apply_func_args_t) add_config_entry_cb, 1, tmp TSRMLS_CC);
+ add_assoc_zval_ex(retval, hash_key->arKey, hash_key->nKeyLength, tmp);
+ }
+ return 0;
+}
+/* }}} */
+
+/* {{{ proto mixed get_cfg_var(string option_name)
Get the value of a PHP configuration option */
PHP_FUNCTION(get_cfg_var)
{
- zval **varname;
- char *value;
+ zval **varname, *retval;
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &varname) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -4860,10 +4897,19 @@ PHP_FUNCTION(get_cfg_var)
convert_to_string_ex(varname);
- if (cfg_get_string(Z_STRVAL_PP(varname), &value) == FAILURE) {
+ retval = cfg_get_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname) + 1);
+
+ if (retval) {
+ if (Z_TYPE_P(retval) == IS_ARRAY) {
+ array_init(return_value);
+ zend_hash_apply_with_arguments(Z_ARRVAL_P(retval), (apply_func_args_t) add_config_entry_cb, 1, return_value TSRMLS_CC);
+ return;
+ } else {
+ RETURN_STRING(Z_STRVAL_P(retval), 1);
+ }
+ } else {
RETURN_FALSE;
}
- RETURN_STRING(value, 1);
}
/* }}} */
@@ -5576,7 +5622,7 @@ PHP_FUNCTION(ini_get)
convert_to_string_ex(varname);
- str = zend_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 0);
+ str = zend_ini_string(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname) + 1, 0);
if (!str) {
RETURN_FALSE;
@@ -5713,8 +5759,7 @@ PHP_FUNCTION(ini_set)
}
}
- if (zend_alter_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value),
- PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == FAILURE) {
+ if (zend_alter_ini_entry_ex(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname) + 1, Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
@@ -5739,7 +5784,6 @@ PHP_FUNCTION(ini_restore)
/* {{{ proto string set_include_path(string new_include_path)
Sets the include_path configuration option */
-
PHP_FUNCTION(set_include_path)
{
zval **new_value;
@@ -5756,19 +5800,15 @@ PHP_FUNCTION(set_include_path)
} else {
RETVAL_FALSE;
}
- if (zend_alter_ini_entry("include_path", sizeof("include_path"),
- Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value),
- PHP_INI_USER, PHP_INI_STAGE_RUNTIME) == FAILURE) {
+ if (zend_alter_ini_entry_ex("include_path", sizeof("include_path"), Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
}
-
/* }}} */
/* {{{ proto string get_include_path()
Get the current include_path configuration option */
-
PHP_FUNCTION(get_include_path)
{
char *str;
@@ -5781,22 +5821,18 @@ PHP_FUNCTION(get_include_path)
}
RETURN_STRING(str, 1);
}
-
/* }}} */
/* {{{ proto void restore_include_path()
Restore the value of the include_path configuration option */
-
PHP_FUNCTION(restore_include_path)
{
if (ZEND_NUM_ARGS() != 0) {
WRONG_PARAM_COUNT;
}
- zend_restore_ini_entry("include_path", sizeof("include_path"),
- PHP_INI_STAGE_RUNTIME);
+ zend_restore_ini_entry("include_path", sizeof("include_path"), PHP_INI_STAGE_RUNTIME);
}
-
/* }}} */
/* {{{ proto mixed print_r(mixed var [, bool return])
@@ -5861,7 +5897,7 @@ PHP_FUNCTION(ignore_user_abort)
RETURN_FALSE;
}
convert_to_string_ex(arg);
- zend_alter_ini_entry("ignore_user_abort", sizeof("ignore_user_abort"), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), PHP_INI_USER, PHP_INI_STAGE_RUNTIME);
+ zend_alter_ini_entry_ex("ignore_user_abort", sizeof("ignore_user_abort"), Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), PHP_INI_USER, PHP_INI_STAGE_RUNTIME, 0 TSRMLS_CC);
break;
default:
@@ -6116,7 +6152,7 @@ PHP_FUNCTION(move_uploaded_file)
/* {{{ php_simple_ini_parser_cb
*/
-static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type, zval *arr)
+static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *arr TSRMLS_DC)
{
zval *element;
@@ -6146,11 +6182,11 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
if (!(Z_STRLEN_P(arg1) > 1 && Z_STRVAL_P(arg1)[0] == '0') && is_numeric_string(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1), NULL, NULL, 0) == IS_LONG) {
ulong key = (ulong) zend_atoi(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
if (zend_hash_index_find(Z_ARRVAL_P(arr), key, (void **) &find_hash) == FAILURE) {
- ALLOC_ZVAL(hash);
- INIT_PZVAL(hash);
- array_init(hash);
+ ALLOC_ZVAL(hash);
+ INIT_PZVAL(hash);
+ array_init(hash);
- zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash, sizeof(zval *), NULL);
+ zend_hash_index_update(Z_ARRVAL_P(arr), key, &hash, sizeof(zval *), NULL);
} else {
hash = *find_hash;
}
@@ -6176,7 +6212,12 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
*element = *arg2;
zval_copy_ctor(element);
INIT_PZVAL(element);
- add_next_index_zval(hash, element);
+
+ if (arg3 && Z_STRLEN_P(arg3) > 0) {
+ add_assoc_zval_ex(hash, Z_STRVAL_P(arg3), Z_STRLEN_P(arg3) + 1, element);
+ } else {
+ add_next_index_zval(hash, element);
+ }
}
break;
@@ -6188,10 +6229,8 @@ static void php_simple_ini_parser_cb(zval *arg1, zval *arg2, int callback_type,
/* {{{ php_ini_parser_cb_with_sections
*/
-static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback_type, zval *arr)
+static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, zval *arg3, int callback_type, zval *arr TSRMLS_DC)
{
- TSRMLS_FETCH();
-
if (callback_type == ZEND_INI_PARSER_SECTION) {
MAKE_STD_ZVAL(BG(active_ini_file_section));
array_init(BG(active_ini_file_section));
@@ -6205,59 +6244,62 @@ static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int callback
active_arr = arr;
}
- php_simple_ini_parser_cb(arg1, arg2, callback_type, active_arr);
+ php_simple_ini_parser_cb(arg1, arg2, arg3, callback_type, active_arr TSRMLS_CC);
}
}
/* }}} */
-/* {{{ proto array parse_ini_file(string filename [, bool process_sections])
+/* {{{ proto array parse_ini_file(string filename [, bool process_sections [, int scanner_mode]])
Parse configuration file */
PHP_FUNCTION(parse_ini_file)
{
- zval **filename, **process_sections;
+ char *filename = NULL;
+ int filename_len = 0;
+ zend_bool process_sections = 0;
+ long scanner_mode = ZEND_INI_SCANNER_NORMAL;
zend_file_handle fh;
zend_ini_parser_cb_t ini_parser_cb;
- switch (ZEND_NUM_ARGS()) {
-
- case 1:
- if (zend_get_parameters_ex(1, &filename) == FAILURE) {
- RETURN_FALSE;
- }
- ini_parser_cb = (zend_ini_parser_cb_t) php_simple_ini_parser_cb;
- break;
-
- case 2:
- if (zend_get_parameters_ex(2, &filename, &process_sections) == FAILURE) {
- RETURN_FALSE;
- }
-
- convert_to_boolean_ex(process_sections);
-
- if (Z_BVAL_PP(process_sections)) {
- BG(active_ini_file_section) = NULL;
- ini_parser_cb = (zend_ini_parser_cb_t) php_ini_parser_cb_with_sections;
- } else {
- ini_parser_cb = (zend_ini_parser_cb_t) php_simple_ini_parser_cb;
- }
- break;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bl", &filename, &filename_len, &process_sections, &scanner_mode) == FAILURE) {
+ RETURN_FALSE;
+ }
- default:
- ZEND_WRONG_PARAM_COUNT();
- break;
+ if (filename_len == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename can not be empty!");
+ RETURN_FALSE;
}
- convert_to_string_ex(filename);
+ /* Set callback function */
+ if (process_sections) {
+ BG(active_ini_file_section) = NULL;
+ ini_parser_cb = (zend_ini_parser_cb_t) php_ini_parser_cb_with_sections;
+ } else {
+ ini_parser_cb = (zend_ini_parser_cb_t) php_simple_ini_parser_cb;
+ }
+ /* Setup filehandle */
memset(&fh, 0, sizeof(fh));
- fh.filename = Z_STRVAL_PP(filename);
- Z_TYPE(fh) = ZEND_HANDLE_FILENAME;
+ fh.filename = filename;
+ fh.type = ZEND_HANDLE_FILENAME;
array_init(return_value);
- zend_parse_ini_file(&fh, 0, ini_parser_cb, return_value);
+ zend_parse_ini_file(&fh, 0, scanner_mode, ini_parser_cb, return_value TSRMLS_CC);
}
/* }}} */
+#if ZEND_DEBUG
+/* {{{ proto void dump_config_hash(void)
+ */
+PHP_FUNCTION(dump_config_hash)
+{
+ HashTable hash = get_configuration_hash();
+
+ array_init(return_value);
+ zend_hash_apply_with_arguments(&hash, (apply_func_args_t) add_config_entry_cb, 1, return_value TSRMLS_CC);
+}
+/* }}} */
+#endif
+
static int copy_request_variable(void *pDest, int num_args, va_list args, zend_hash_key *hash_key)
{
char *prefix, *new_key;
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index 549e3acdf1..bda93e3c67 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -125,6 +125,9 @@ PHP_FUNCTION(move_uploaded_file);
/* From the INI parser */
PHP_FUNCTION(parse_ini_file);
+#if ZEND_DEBUG
+PHP_FUNCTION(dump_config_hash);
+#endif
PHP_FUNCTION(str_rot13);
PHP_FUNCTION(stream_get_filters);
diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c
index 1c5bd70ba4..1d68ad141d 100644
--- a/ext/standard/browscap.c
+++ b/ext/standard/browscap.c
@@ -23,11 +23,12 @@
#include "php_browscap.h"
#include "php_ini.h"
#include "php_string.h"
-
+#include "zend_ini_scanner.h"
#include "zend_globals.h"
static HashTable browser_hash;
static zval *current_section;
+static char *current_section_name;
#define DEFAULT_SECTION_NAME "Default Browser Capability Settings"
@@ -88,7 +89,7 @@ static void convert_browscap_pattern(zval *pattern)
/* {{{ php_browscap_parser_cb
*/
-static void php_browscap_parser_cb(zval *arg1, zval *arg2, int callback_type, void *arg)
+static void php_browscap_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC)
{
if (!arg1) {
return;
@@ -100,12 +101,37 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, int callback_type, vo
zval *new_property;
char *new_key;
+ /* parent entry can not be same as current section -> causes infinite loop! */
+ if (!strcasecmp(Z_STRVAL_P(arg1), "parent") &&
+ !strcasecmp(current_section_name, Z_STRVAL_P(arg2))
+ ) {
+ zend_error(E_CORE_ERROR, "Invalid browscap ini file: 'Parent' value can not be same as the section name: %s (in file %s)", current_section_name, INI_STR("browscap"));
+ return;
+ }
+
new_property = (zval *) pemalloc(sizeof(zval), 1);
INIT_PZVAL(new_property);
- Z_STRVAL_P(new_property) = zend_strndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
- Z_STRLEN_P(new_property) = Z_STRLEN_P(arg2);
Z_TYPE_P(new_property) = IS_STRING;
+ /* Set proper value for true/false settings */
+ if ((Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "on", sizeof("on") - 1)) ||
+ (Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "yes", sizeof("yes") - 1)) ||
+ (Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "true", sizeof("true") - 1))
+ ) {
+ Z_STRVAL_P(new_property) = zend_strndup("1", 1);
+ Z_STRLEN_P(new_property) = 1;
+ } else if (
+ (Z_STRLEN_P(arg2) == 2 && !strncasecmp(Z_STRVAL_P(arg2), "no", sizeof("no") - 1)) ||
+ (Z_STRLEN_P(arg2) == 3 && !strncasecmp(Z_STRVAL_P(arg2), "off", sizeof("off") - 1)) ||
+ (Z_STRLEN_P(arg2) == 4 && !strncasecmp(Z_STRVAL_P(arg2), "none", sizeof("none") - 1)) ||
+ (Z_STRLEN_P(arg2) == 5 && !strncasecmp(Z_STRVAL_P(arg2), "false", sizeof("false") - 1))
+ ) {
+ Z_STRVAL_P(new_property) = zend_strndup("", 0);
+ Z_STRLEN_P(new_property) = 0;
+ } else { /* Other than true/false setting */
+ Z_STRVAL_P(new_property) = zend_strndup(Z_STRVAL_P(arg2), Z_STRLEN_P(arg2));
+ Z_STRLEN_P(new_property) = Z_STRLEN_P(arg2);
+ }
new_key = zend_strndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
zend_str_tolower(new_key, Z_STRLEN_P(arg1));
zend_hash_update(Z_ARRVAL_P(current_section), new_key, Z_STRLEN_P(arg1)+1, &new_property, sizeof(zval *), NULL);
@@ -127,8 +153,10 @@ static void php_browscap_parser_cb(zval *arg1, zval *arg2, int callback_type, vo
section_properties = (HashTable *) pemalloc(sizeof(HashTable), 1);
zend_hash_init(section_properties, 0, NULL, (dtor_func_t) browscap_entry_dtor, 1);
- current_section->value.ht = section_properties;
- current_section->type = IS_ARRAY;
+ Z_ARRVAL_P(current_section) = section_properties;
+ Z_TYPE_P(current_section) = IS_ARRAY;
+ current_section_name = zend_strndup(Z_STRVAL_P(arg1), Z_STRLEN_P(arg1));
+
zend_hash_update(&browser_hash, Z_STRVAL_P(arg1), Z_STRLEN_P(arg1)+1, (void *) &current_section, sizeof(zval *), NULL);
Z_STRVAL_P(processed) = Z_STRVAL_P(arg1);
@@ -171,7 +199,7 @@ PHP_MINIT_FUNCTION(browscap)
}
fh.filename = browscap;
Z_TYPE(fh) = ZEND_HANDLE_FP;
- zend_parse_ini_file(&fh, 1, (zend_ini_parser_cb_t) php_browscap_parser_cb, &browser_hash);
+ zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_RAW, (zend_ini_parser_cb_t) php_browscap_parser_cb, &browser_hash TSRMLS_CC);
}
return SUCCESS;
diff --git a/ext/standard/tests/file/parse_ini_file.phpt b/ext/standard/tests/file/parse_ini_file.phpt
index 741b03af8d..dab07e56e7 100644
--- a/ext/standard/tests/file/parse_ini_file.phpt
+++ b/ext/standard/tests/file/parse_ini_file.phpt
@@ -50,98 +50,98 @@ Hex_Value2 = 0x103
[Non-alphanumerics_as_values]
;Non-alpha numeric chars without quotes
-Non-alpha1 = ;
-Non-alpha2 = +
-Non-alpha3 = *
-Non-alpha4 = %
-Non-alpha5 = <>
-Non-alpha6 = @
-Non-alpha7 = #
-Non-alpha8 = ^
-non-alpha9 = -
-Non-alpha10 = :
-Non-alpha11 = ?
-Non-alpha12 = /
-Non-alpha13 = \
+Non_alpha1 = ;
+Non_alpha2 = +
+Non_alpha3 = *
+Non_alpha4 = %
+Non_alpha5 = <>
+Non_alpha6 = @
+Non_alpha7 = #
+Non_alpha8 = ^
+Non_alpha9 = -
+Non_alpha10 = :
+Non_alpha11 = ?
+Non_alpha12 = /
+Non_alpha13 = \
;These chars have a special meaning when used in the value,
; hence parser throws an error
-;Non-alpha14 = &
-;Non-alpha15 = {}
-;Non-alpha16 = |
-;Non-alpha17 = ~
-;Non-alpha18 = !
-;Non-alpha19 = $
-;Non-alpha20 = ()
-
-Non-alpha1_quotes = ";"
-Non-alpha2_quotes = "+"
-Non-alpha3_quotes = "*"
-Non-alpha4_quotes = "%"
-Non-alpha5_quotes = "<>"
-Non-alpha6_quotes = "@"
-Non-alpha7_quotes = "#"
-Non-alpha8_quotes = "^"
-Non-alpha9_quotes = "-"
-Non-alpha10_quotes = "="
-Non-alpha11_quotes = ":"
-Non-alpha12_quotes = "?"
-Non-alpha13_quotes = "/"
-Non-alpha14_quotes = "\"
-Non-alpha15_quotes = "&"
-Non-alpha16_quotes = "{}"
-Non-alpha17_quotes = "|"
-Non-alpha18_quotes = "~"
-Non-alpha19_quotes = "!"
-non-alpha20_quotes = "$"
-non-alpha21_quotes = "()"
+;Non_alpha14 = &
+;Non_alpha15 = {}
+;Non_alpha16 = |
+;Non_alpha17 = ~
+;Non_alpha18 = !
+;Non_alpha19 = $
+;Non_alpha20 = ()
+
+Non_alpha1_quotes = ";"
+Non_alpha2_quotes = "+"
+Non_alpha3_quotes = "*"
+Non_alpha4_quotes = "%"
+Non_alpha5_quotes = "<>"
+Non_alpha6_quotes = "@"
+Non_alpha7_quotes = "#"
+Non_alpha8_quotes = "^"
+Non_alpha9_quotes = "-"
+Non_alpha10_quotes = "="
+Non_alpha11_quotes = ":"
+Non_alpha12_quotes = "?"
+Non_alpha13_quotes = "/"
+;Non_alpha14_quotes = "\"
+Non_alpha15_quotes = "&"
+Non_alpha16_quotes = "{}"
+Non_alpha17_quotes = "|"
+Non_alpha18_quotes = "~"
+Non_alpha19_quotes = "!"
+;Non_alpha20_quotes = "$"
+Non_alpha21_quotes = "()"
[Non-alpha numerics in strings]
;expected error, as the non-alphanumeric chars not enclosed in double quotes("")
-Non-alpha_string1 = Hello@world
-;Non-alpha_string2 = Hello!world
-;Non-alpha_string3 = Hello#world
-;Non-alpha_string4 = Hello%world
-;Non-alpha_string5 = Hello&world
-;Non-alpha_string6 = Hello*world
-;Non-alpha_string7 = Hello+world
-;Non-alpha_string8 = Hello-world
-;Non-alpha_string9 = Hello'world
-;Non-alpha_string10 = Hello:world
-;Non-alpha_string11 = Hello;world
-;Non-alpha_string12 = Hello<world
-;Non-alpha_string13 = Hello>world
-;Non-alpha_string14 = Hello>world
-;Non-alpha_string15 = Hello?world
-;Non-alpha_string16 = Hello\world
-;Non-alpha_string17 = Hello^world
-;Non-alpha_string18 = Hello_world
-;Non-alpha_string19 = Hello|world
-;Non-alpha_string20 = Hello~world
-;Non-alpha_string21 = Hello`world
-;Non-alpha_string22 = Hello(world)
+Non_alpha_string1 = Hello@world
+;Non_alpha_string2 = Hello!world
+;Non_alpha_string3 = Hello#world
+;Non_alpha_string4 = Hello%world
+;Non_alpha_string5 = Hello&world
+;Non_alpha_string6 = Hello*world
+;Non_alpha_string7 = Hello+world
+;Non_alpha_string8 = Hello-world
+;Non_alpha_string9 = Hello'world
+;Non_alpha_string10 = Hello:world
+;Non_alpha_string11 = Hello;world
+;Non_alpha_string12 = Hello<world
+;Non_alpha_string13 = Hello>world
+;Non_alpha_string14 = Hello>world
+;Non_alpha_string15 = Hello?world
+;Non_alpha_string16 = Hello\world
+;Non_alpha_string17 = Hello^world
+;Non_alpha_string18 = Hello_world
+;Non_alpha_string19 = Hello|world
+;Non_alpha_string20 = Hello~world
+;Non_alpha_string21 = Hello`world
+;Non_alpha_string22 = Hello(world)
[Non-alpha numerics in strings -with quotes]
-Non-alpha_string1_quotes = "Hello@world"
-Non-alpha_string2_quotes = "Hello!world"
-Non-alpha_string3_quotes = "Hello#world"
-Non-alpha_string4_quotes = "Hello&world"
-Non-alpha_string5_quotes = "Hello*world"
-Non-alpha_string6_quotes = "Hello+world"
-Non-alpha_string7_quotes = "Hello-world"
-Non-alpha_string8_quotes = "Hello'world"
-Non-alpha_string9_quotes = "Hello:world"
-Non-alpha_string10_quotes = "Hello;world"
-Non-alpha_string11_quotes = "Hello<world"
-Non-alpha_string12_quotes = "Hello>world"
-Non-alpha_string13_quotes = "Hello>world"
-Non-alpha_string14_quotes = "Hello?world"
-Non-alpha_string15_quotes = "Hello\world"
-Non-alpha_string16_quotes = "Hello^world"
-Non-alpha_string17_quotes = "Hello_world"
-Non-alpha_string18_quotes = "Hello|world"
-Non-alpha_string19_quotes = "Hello~world"
-Non-alpha_string20_quotes = "Hello`world"
-Non-alpha_string21_quotes = "Hello(world)"
+Non_alpha_string1_quotes = "Hello@world"
+Non_alpha_string2_quotes = "Hello!world"
+Non_alpha_string3_quotes = "Hello#world"
+Non_alpha_string4_quotes = "Hello&world"
+Non_alpha_string5_quotes = "Hello*world"
+Non_alpha_string6_quotes = "Hello+world"
+Non_alpha_string7_quotes = "Hello-world"
+Non_alpha_string8_quotes = "Hello'world"
+Non_alpha_string9_quotes = "Hello:world"
+Non_alpha_string10_quotes = "Hello;world"
+Non_alpha_string11_quotes = "Hello<world"
+Non_alpha_string12_quotes = "Hello>world"
+Non_alpha_string13_quotes = "Hello>world"
+Non_alpha_string14_quotes = "Hello?world"
+Non_alpha_string15_quotes = "Hello\world"
+Non_alpha_string16_quotes = "Hello^world"
+Non_alpha_string17_quotes = "Hello_world"
+Non_alpha_string18_quotes = "Hello|world"
+Non_alpha_string19_quotes = "Hello~world"
+Non_alpha_string20_quotes = "Hello`world"
+Non_alpha_string21_quotes = "Hello(world)"
[Newlines_in_Values]
String1 = "Hello, world\nGood Morning"
@@ -150,7 +150,7 @@ String2 = "\nHello, world
String3 = 'Hello, world\tGood Morning'
String4 = "\n"
String5 = "\n\n"
-String3 = Hello, world\tGood Morning
+String6 = Hello, world\tGood Morning
[ReservedKeys_as_Values]
Key1 = YES
@@ -242,74 +242,73 @@ Array
[Octal_value] => 0100
[Hex_value1] => 0x101
[Hex_Value2] => 0x103
- [Non-alpha1] =>
- [Non-alpha2] => +
- [Non-alpha3] => *
- [Non-alpha4] => %
- [Non-alpha5] => <>
- [Non-alpha6] => @
- [Non-alpha7] => #
- [Non-alpha8] => ^
- [non-alpha9] => -
- [Non-alpha10] => :
- [Non-alpha11] => ?
- [Non-alpha12] => /
- [Non-alpha13] => \
- [Non-alpha1_quotes] => ;
- [Non-alpha2_quotes] => +
- [Non-alpha3_quotes] => *
- [Non-alpha4_quotes] => %
- [Non-alpha5_quotes] => <>
- [Non-alpha6_quotes] => @
- [Non-alpha7_quotes] => #
- [Non-alpha8_quotes] => ^
- [Non-alpha9_quotes] => -
- [Non-alpha10_quotes] => =
- [Non-alpha11_quotes] => :
- [Non-alpha12_quotes] => ?
- [Non-alpha13_quotes] => /
- [Non-alpha14_quotes] => \
- [Non-alpha15_quotes] => &
- [Non-alpha16_quotes] => {}
- [Non-alpha17_quotes] => |
- [Non-alpha18_quotes] => ~
- [Non-alpha19_quotes] => !
- [non-alpha20_quotes] => $
- [non-alpha21_quotes] => ()
- [Non-alpha_string1] => Hello@world
- [Non-alpha_string1_quotes] => Hello@world
- [Non-alpha_string2_quotes] => Hello!world
- [Non-alpha_string3_quotes] => Hello#world
- [Non-alpha_string4_quotes] => Hello&world
- [Non-alpha_string5_quotes] => Hello*world
- [Non-alpha_string6_quotes] => Hello+world
- [Non-alpha_string7_quotes] => Hello-world
- [Non-alpha_string8_quotes] => Hello'world
- [Non-alpha_string9_quotes] => Hello:world
- [Non-alpha_string10_quotes] => Hello;world
- [Non-alpha_string11_quotes] => Hello<world
- [Non-alpha_string12_quotes] => Hello>world
- [Non-alpha_string13_quotes] => Hello>world
- [Non-alpha_string14_quotes] => Hello?world
- [Non-alpha_string15_quotes] => Hello\world
- [Non-alpha_string16_quotes] => Hello^world
- [Non-alpha_string17_quotes] => Hello_world
- [Non-alpha_string18_quotes] => Hello|world
- [Non-alpha_string19_quotes] => Hello~world
- [Non-alpha_string20_quotes] => Hello`world
- [Non-alpha_string21_quotes] => Hello(world)
+ [Non_alpha1] =>
+ [Non_alpha2] => +
+ [Non_alpha3] => *
+ [Non_alpha4] => %
+ [Non_alpha5] => <>
+ [Non_alpha6] => @
+ [Non_alpha7] => #
+ [Non_alpha8] => ^
+ [Non_alpha9] => -
+ [Non_alpha10] => :
+ [Non_alpha11] => ?
+ [Non_alpha12] => /
+ [Non_alpha13] => \
+ [Non_alpha1_quotes] => ;
+ [Non_alpha2_quotes] => +
+ [Non_alpha3_quotes] => *
+ [Non_alpha4_quotes] => %
+ [Non_alpha5_quotes] => <>
+ [Non_alpha6_quotes] => @
+ [Non_alpha7_quotes] => #
+ [Non_alpha8_quotes] => ^
+ [Non_alpha9_quotes] => -
+ [Non_alpha10_quotes] => =
+ [Non_alpha11_quotes] => :
+ [Non_alpha12_quotes] => ?
+ [Non_alpha13_quotes] => /
+ [Non_alpha15_quotes] => &
+ [Non_alpha16_quotes] => {}
+ [Non_alpha17_quotes] => |
+ [Non_alpha18_quotes] => ~
+ [Non_alpha19_quotes] => !
+ [Non_alpha21_quotes] => ()
+ [Non_alpha_string1] => Hello@world
+ [Non_alpha_string1_quotes] => Hello@world
+ [Non_alpha_string2_quotes] => Hello!world
+ [Non_alpha_string3_quotes] => Hello#world
+ [Non_alpha_string4_quotes] => Hello&world
+ [Non_alpha_string5_quotes] => Hello*world
+ [Non_alpha_string6_quotes] => Hello+world
+ [Non_alpha_string7_quotes] => Hello-world
+ [Non_alpha_string8_quotes] => Hello'world
+ [Non_alpha_string9_quotes] => Hello:world
+ [Non_alpha_string10_quotes] => Hello;world
+ [Non_alpha_string11_quotes] => Hello<world
+ [Non_alpha_string12_quotes] => Hello>world
+ [Non_alpha_string13_quotes] => Hello>world
+ [Non_alpha_string14_quotes] => Hello?world
+ [Non_alpha_string15_quotes] => Hello\world
+ [Non_alpha_string16_quotes] => Hello^world
+ [Non_alpha_string17_quotes] => Hello_world
+ [Non_alpha_string18_quotes] => Hello|world
+ [Non_alpha_string19_quotes] => Hello~world
+ [Non_alpha_string20_quotes] => Hello`world
+ [Non_alpha_string21_quotes] => Hello(world)
[String1] => Hello, world
Good Morning
[String2] =>
Hello, world
Good Morning
- [String3] => Hello, worldGood Morning
+ [String3] => Hello, world Good Morning
[String4] =>
[String5] =>
+ [String6] => Hello, world Good Morning
[Key1] => 1
[Key2] => 1
[Key3] => 1
@@ -379,70 +378,68 @@ Array
[Non-alphanumerics_as_values] => Array
(
- [Non-alpha1] =>
- [Non-alpha2] => +
- [Non-alpha3] => *
- [Non-alpha4] => %
- [Non-alpha5] => <>
- [Non-alpha6] => @
- [Non-alpha7] => #
- [Non-alpha8] => ^
- [non-alpha9] => -
- [Non-alpha10] => :
- [Non-alpha11] => ?
- [Non-alpha12] => /
- [Non-alpha13] => \
- [Non-alpha1_quotes] => ;
- [Non-alpha2_quotes] => +
- [Non-alpha3_quotes] => *
- [Non-alpha4_quotes] => %
- [Non-alpha5_quotes] => <>
- [Non-alpha6_quotes] => @
- [Non-alpha7_quotes] => #
- [Non-alpha8_quotes] => ^
- [Non-alpha9_quotes] => -
- [Non-alpha10_quotes] => =
- [Non-alpha11_quotes] => :
- [Non-alpha12_quotes] => ?
- [Non-alpha13_quotes] => /
- [Non-alpha14_quotes] => \
- [Non-alpha15_quotes] => &
- [Non-alpha16_quotes] => {}
- [Non-alpha17_quotes] => |
- [Non-alpha18_quotes] => ~
- [Non-alpha19_quotes] => !
- [non-alpha20_quotes] => $
- [non-alpha21_quotes] => ()
+ [Non_alpha1] =>
+ [Non_alpha2] => +
+ [Non_alpha3] => *
+ [Non_alpha4] => %
+ [Non_alpha5] => <>
+ [Non_alpha6] => @
+ [Non_alpha7] => #
+ [Non_alpha8] => ^
+ [Non_alpha9] => -
+ [Non_alpha10] => :
+ [Non_alpha11] => ?
+ [Non_alpha12] => /
+ [Non_alpha13] => \
+ [Non_alpha1_quotes] => ;
+ [Non_alpha2_quotes] => +
+ [Non_alpha3_quotes] => *
+ [Non_alpha4_quotes] => %
+ [Non_alpha5_quotes] => <>
+ [Non_alpha6_quotes] => @
+ [Non_alpha7_quotes] => #
+ [Non_alpha8_quotes] => ^
+ [Non_alpha9_quotes] => -
+ [Non_alpha10_quotes] => =
+ [Non_alpha11_quotes] => :
+ [Non_alpha12_quotes] => ?
+ [Non_alpha13_quotes] => /
+ [Non_alpha15_quotes] => &
+ [Non_alpha16_quotes] => {}
+ [Non_alpha17_quotes] => |
+ [Non_alpha18_quotes] => ~
+ [Non_alpha19_quotes] => !
+ [Non_alpha21_quotes] => ()
)
[Non-alpha numerics in strings] => Array
(
- [Non-alpha_string1] => Hello@world
+ [Non_alpha_string1] => Hello@world
)
[Non-alpha numerics in strings -with quotes] => Array
(
- [Non-alpha_string1_quotes] => Hello@world
- [Non-alpha_string2_quotes] => Hello!world
- [Non-alpha_string3_quotes] => Hello#world
- [Non-alpha_string4_quotes] => Hello&world
- [Non-alpha_string5_quotes] => Hello*world
- [Non-alpha_string6_quotes] => Hello+world
- [Non-alpha_string7_quotes] => Hello-world
- [Non-alpha_string8_quotes] => Hello'world
- [Non-alpha_string9_quotes] => Hello:world
- [Non-alpha_string10_quotes] => Hello;world
- [Non-alpha_string11_quotes] => Hello<world
- [Non-alpha_string12_quotes] => Hello>world
- [Non-alpha_string13_quotes] => Hello>world
- [Non-alpha_string14_quotes] => Hello?world
- [Non-alpha_string15_quotes] => Hello\world
- [Non-alpha_string16_quotes] => Hello^world
- [Non-alpha_string17_quotes] => Hello_world
- [Non-alpha_string18_quotes] => Hello|world
- [Non-alpha_string19_quotes] => Hello~world
- [Non-alpha_string20_quotes] => Hello`world
- [Non-alpha_string21_quotes] => Hello(world)
+ [Non_alpha_string1_quotes] => Hello@world
+ [Non_alpha_string2_quotes] => Hello!world
+ [Non_alpha_string3_quotes] => Hello#world
+ [Non_alpha_string4_quotes] => Hello&world
+ [Non_alpha_string5_quotes] => Hello*world
+ [Non_alpha_string6_quotes] => Hello+world
+ [Non_alpha_string7_quotes] => Hello-world
+ [Non_alpha_string8_quotes] => Hello'world
+ [Non_alpha_string9_quotes] => Hello:world
+ [Non_alpha_string10_quotes] => Hello;world
+ [Non_alpha_string11_quotes] => Hello<world
+ [Non_alpha_string12_quotes] => Hello>world
+ [Non_alpha_string13_quotes] => Hello>world
+ [Non_alpha_string14_quotes] => Hello?world
+ [Non_alpha_string15_quotes] => Hello\world
+ [Non_alpha_string16_quotes] => Hello^world
+ [Non_alpha_string17_quotes] => Hello_world
+ [Non_alpha_string18_quotes] => Hello|world
+ [Non_alpha_string19_quotes] => Hello~world
+ [Non_alpha_string20_quotes] => Hello`world
+ [Non_alpha_string21_quotes] => Hello(world)
)
[Newlines_in_Values] => Array
@@ -453,12 +450,13 @@ Good Morning
Hello, world
Good Morning
- [String3] => Hello, worldGood Morning
+ [String3] => Hello, world Good Morning
[String4] =>
[String5] =>
+ [String6] => Hello, world Good Morning
)
[ReservedKeys_as_Values] => Array
@@ -488,4 +486,4 @@ Hello, world
)
)
-*** Done ** \ No newline at end of file
+*** Done **
diff --git a/ext/standard/tests/general_functions/parse_ini_basic.data b/ext/standard/tests/general_functions/parse_ini_basic.data
new file mode 100644
index 0000000000..cba8f9d70f
--- /dev/null
+++ b/ext/standard/tests/general_functions/parse_ini_basic.data
@@ -0,0 +1,106 @@
+[basic]
+basicval = bar
+longval = 12345
+with.dot = fooobar
+boolon = on
+booltrue = true
+boolyes = yes
+booloff = off
+boolfalse = false
+boolnone = none
+boolno = no
+string = asdadfsdjkslkj ¡@£$$ { }[ ]/%#¤
+sqstring = 'adsasdadasdasd'
+dqstring = "asdadfsdjkslkj ¡@£$$ { } !^~|¥¥{[()/)&/% ¤ # #"
+php_constant = E_ALL
+
+[basic with whitespace]
+basicval = bar
+longval = 12345
+with.dot = fooobar
+boolon = on
+booltrue = true
+boolyes = yes
+booloff = off
+boolfalse = false
+boolnone = none
+boolno = no
+sqstring = 'adsasdadasdasd'
+dqstring = "asdadfsdjkslkj ¡@£$$€¥¥{[()/)&/%#¤"
+php_constant = E_ALL
+
+[comments]
+; some comment
+ ; some comment with whitespace
+somecomment = comment follows;aaa@bbb ; comment here
+;
+
+[variables]
+var1 = ${basicval}
+var2 = ${basicval}/foo
+var3 = foo/${basicval}
+var4 = foo/${basicval}/foo
+quoted_var1 = "${basicqval}"
+quoted_var2 = "${basicqval}/foo"
+quoted_var3 = "foo/${basicqval}"
+quoted_var4 = "foo/${basicqval}/foo"
+
+[offset values]
+foo1[] = "basic offset 1"
+foo1[ ] = "basic offset 2"
+foo2[123] = "long offset"
+foo3[abc] = "string offset"
+foo4[""] = "quoted offset 1"
+foo4[" "] = "quoted offset 2"
+foo4["sqfoobar"] = "quoted string offset"
+foo4['dqfoobar'] = "single quoted offset"
+foo6[${basicval}] = "variable"
+foo6[${basicval}/foo] = "variable with string 1"
+foo6[foo/${basicval}] = "variable with string 2"
+foo6[foo/${basicval}/foo] = "variable with string 3"
+foo7["${basicqval}"] = "quoted variable 1"
+foo7["${basicqval}/foo"] = "quoted variable 2"
+foo7["foo/${basicqval}"] = "quoted variable 3"
+foo7[ "foo/${basicqval}/foo" ] = "quoted variable 4"
+
+[non value]
+novalue_option1 =
+novalue_option2=
+novalue_option3 =
+novalue_option4=
+novalue_option4[] =
+novalue_option4[]=
+novalue_option4[]=
+
+["Quoted strings and variables in sections"]
+
+[${basicval}]
+[${basicval}/foo]
+[foo/${basicval}]
+[foo/${basicval}/foo]
+
+["${basicqval}"]
+["${basicqval}/foo"]
+["foo/${basicqval}"]
+["foo/${basicqval}/foo"]
+
+[PATH=${basicval}/no/quotes]
+; Invalid!
+;[PATH="${basicval}/path/quoted"]
+["PATH=${basicval}/all/quoted"]
+
+; The rest is from bug #29306
+[01]
+e=e
+f=f
+[02]
+g=g
+h=h
+[1]
+a=a
+b=b
+[2]
+c=c
+d=d
+[0815]
+bla=bla
diff --git a/ext/standard/tests/general_functions/parse_ini_basic.phpt b/ext/standard/tests/general_functions/parse_ini_basic.phpt
new file mode 100644
index 0000000000..7ab95d7dc0
--- /dev/null
+++ b/ext/standard/tests/general_functions/parse_ini_basic.phpt
@@ -0,0 +1,239 @@
+--TEST--
+parse_ini_file() tests
+--ENV--
+basicval=FUBAR_VARIABLE
+basicqval=FUBAR_QUOTES_VARIABLE
+--FILE--
+<?php
+
+$ini_file = dirname(__FILE__)."/parse_ini_basic.data";
+
+var_dump(parse_ini_file($ini_file, 1));
+
+echo "Done.\n";
+?>
+--EXPECTF--
+array(22) {
+ ["basic"]=>
+ array(14) {
+ ["basicval"]=>
+ string(3) "bar"
+ ["longval"]=>
+ string(5) "12345"
+ ["with.dot"]=>
+ string(7) "fooobar"
+ ["boolon"]=>
+ string(1) "1"
+ ["booltrue"]=>
+ string(1) "1"
+ ["boolyes"]=>
+ string(1) "1"
+ ["booloff"]=>
+ string(0) ""
+ ["boolfalse"]=>
+ string(0) ""
+ ["boolnone"]=>
+ string(0) ""
+ ["boolno"]=>
+ string(0) ""
+ ["string"]=>
+ string(34) "asdadfsdjkslkj ¡@£$$ { }[ ]/%#¤"
+ ["sqstring"]=>
+ string(14) "adsasdadasdasd"
+ ["dqstring"]=>
+ string(51) "asdadfsdjkslkj ¡@£$$ { } !^~|¥¥{[()/)&/% ¤ # #"
+ ["php_constant"]=>
+ string(4) "6143"
+ }
+ ["basic with whitespace"]=>
+ array(13) {
+ ["basicval"]=>
+ string(3) "bar"
+ ["longval"]=>
+ string(5) "12345"
+ ["with.dot"]=>
+ string(7) "fooobar"
+ ["boolon"]=>
+ string(1) "1"
+ ["booltrue"]=>
+ string(1) "1"
+ ["boolyes"]=>
+ string(1) "1"
+ ["booloff"]=>
+ string(0) ""
+ ["boolfalse"]=>
+ string(0) ""
+ ["boolnone"]=>
+ string(0) ""
+ ["boolno"]=>
+ string(0) ""
+ ["sqstring"]=>
+ string(14) "adsasdadasdasd"
+ ["dqstring"]=>
+ string(41) "asdadfsdjkslkj ¡@£$$€¥¥{[()/)&/%#¤"
+ ["php_constant"]=>
+ string(4) "6143"
+ }
+ ["comments"]=>
+ array(1) {
+ ["somecomment"]=>
+ string(15) "comment follows"
+ }
+ ["variables"]=>
+ array(8) {
+ ["var1"]=>
+ string(14) "FUBAR_VARIABLE"
+ ["var2"]=>
+ string(18) "FUBAR_VARIABLE/foo"
+ ["var3"]=>
+ string(18) "foo/FUBAR_VARIABLE"
+ ["var4"]=>
+ string(22) "foo/FUBAR_VARIABLE/foo"
+ ["quoted_var1"]=>
+ string(21) "FUBAR_QUOTES_VARIABLE"
+ ["quoted_var2"]=>
+ string(25) "FUBAR_QUOTES_VARIABLE/foo"
+ ["quoted_var3"]=>
+ string(25) "foo/FUBAR_QUOTES_VARIABLE"
+ ["quoted_var4"]=>
+ string(29) "foo/FUBAR_QUOTES_VARIABLE/foo"
+ }
+ ["offset values"]=>
+ array(6) {
+ ["foo1"]=>
+ array(2) {
+ [0]=>
+ string(14) "basic offset 1"
+ [1]=>
+ string(14) "basic offset 2"
+ }
+ ["foo2"]=>
+ array(1) {
+ [123]=>
+ string(11) "long offset"
+ }
+ ["foo3"]=>
+ array(1) {
+ ["abc"]=>
+ string(13) "string offset"
+ }
+ ["foo4"]=>
+ array(4) {
+ [0]=>
+ string(15) "quoted offset 1"
+ [" "]=>
+ string(15) "quoted offset 2"
+ ["sqfoobar"]=>
+ string(20) "quoted string offset"
+ ["dqfoobar"]=>
+ string(20) "single quoted offset"
+ }
+ ["foo6"]=>
+ array(4) {
+ ["FUBAR_VARIABLE"]=>
+ string(8) "variable"
+ ["FUBAR_VARIABLE/foo"]=>
+ string(22) "variable with string 1"
+ ["foo/FUBAR_VARIABLE"]=>
+ string(22) "variable with string 2"
+ ["foo/FUBAR_VARIABLE/foo"]=>
+ string(22) "variable with string 3"
+ }
+ ["foo7"]=>
+ array(4) {
+ ["FUBAR_QUOTES_VARIABLE"]=>
+ string(17) "quoted variable 1"
+ ["FUBAR_QUOTES_VARIABLE/foo"]=>
+ string(17) "quoted variable 2"
+ ["foo/FUBAR_QUOTES_VARIABLE"]=>
+ string(17) "quoted variable 3"
+ ["foo/FUBAR_QUOTES_VARIABLE/foo"]=>
+ string(17) "quoted variable 4"
+ }
+ }
+ ["non value"]=>
+ array(4) {
+ ["novalue_option1"]=>
+ string(0) ""
+ ["novalue_option2"]=>
+ string(0) ""
+ ["novalue_option3"]=>
+ string(0) ""
+ ["novalue_option4"]=>
+ array(3) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ }
+ }
+ ["Quoted strings and variables in sections"]=>
+ array(0) {
+ }
+ ["FUBAR_VARIABLE"]=>
+ array(0) {
+ }
+ ["FUBAR_VARIABLE/foo"]=>
+ array(0) {
+ }
+ ["foo/FUBAR_VARIABLE"]=>
+ array(0) {
+ }
+ ["foo/FUBAR_VARIABLE/foo"]=>
+ array(0) {
+ }
+ ["FUBAR_QUOTES_VARIABLE"]=>
+ array(0) {
+ }
+ ["FUBAR_QUOTES_VARIABLE/foo"]=>
+ array(0) {
+ }
+ ["foo/FUBAR_QUOTES_VARIABLE"]=>
+ array(0) {
+ }
+ ["foo/FUBAR_QUOTES_VARIABLE/foo"]=>
+ array(0) {
+ }
+ ["PATH=FUBAR_VARIABLE/no/quotes"]=>
+ array(0) {
+ }
+ ["PATH=FUBAR_VARIABLE/all/quoted"]=>
+ array(0) {
+ }
+ ["01"]=>
+ array(2) {
+ ["e"]=>
+ string(1) "e"
+ ["f"]=>
+ string(1) "f"
+ }
+ ["02"]=>
+ array(2) {
+ ["g"]=>
+ string(1) "g"
+ ["h"]=>
+ string(1) "h"
+ }
+ [1]=>
+ array(2) {
+ ["a"]=>
+ string(1) "a"
+ ["b"]=>
+ string(1) "b"
+ }
+ [2]=>
+ array(2) {
+ ["c"]=>
+ string(1) "c"
+ ["d"]=>
+ string(1) "d"
+ }
+ ["0815"]=>
+ array(1) {
+ ["bla"]=>
+ string(3) "bla"
+ }
+}
+Done.
diff --git a/ext/standard/tests/general_functions/parse_ini_booleans.data b/ext/standard/tests/general_functions/parse_ini_booleans.data
new file mode 100644
index 0000000000..2f1c2af214
--- /dev/null
+++ b/ext/standard/tests/general_functions/parse_ini_booleans.data
@@ -0,0 +1,27 @@
+[error_reporting values]
+foo = E_ALL E_NOTICE
+error_reporting = E_ALL
+error_reporting1 = E_COMPILE_ERROR|E_RECOVERABLE_ERROR |E_ERROR|E_CORE_ERROR
+error_reporting2 = E_ALL&~E_NOTICE
+error_reporting3 = E_ALL & ~E_NOTICE
+error_reporting4 = E_ALL & ~E_NOTICE | E_STRICT
+
+[true or false]
+bool_true = true
+bool_yes = yes
+bool_on = on
+bool_false=false
+bool_off =Off
+bool_no=No
+bool_none= NoNe
+bool_null = NULl
+
+[strings]
+string_true = "true"
+string_yes = " yes"
+string_on = " on "
+string_false="false"
+string_off ="Off "
+string_no="No "
+string_none=" NoNe"
+string_null = "NULl"
diff --git a/ext/standard/tests/general_functions/parse_ini_booleans.phpt b/ext/standard/tests/general_functions/parse_ini_booleans.phpt
new file mode 100644
index 0000000000..401e587ff7
--- /dev/null
+++ b/ext/standard/tests/general_functions/parse_ini_booleans.phpt
@@ -0,0 +1,69 @@
+--TEST--
+parse_ini_file() boolean operators
+--FILE--
+<?php
+
+$ini_file = dirname(__FILE__)."/parse_ini_booleans.data";
+
+var_dump(parse_ini_file($ini_file, 1));
+
+echo "Done.\n";
+
+?>
+--EXPECTF--
+array(3) {
+ ["error_reporting values"]=>
+ array(6) {
+ ["foo"]=>
+ string(14) "E_ALL E_NOTICE"
+ ["error_reporting"]=>
+ string(4) "6143"
+ ["error_reporting1"]=>
+ string(4) "4177"
+ ["error_reporting2"]=>
+ string(4) "6135"
+ ["error_reporting3"]=>
+ string(4) "6135"
+ ["error_reporting4"]=>
+ string(4) "8183"
+ }
+ ["true or false"]=>
+ array(8) {
+ ["bool_true"]=>
+ string(1) "1"
+ ["bool_yes"]=>
+ string(1) "1"
+ ["bool_on"]=>
+ string(1) "1"
+ ["bool_false"]=>
+ string(0) ""
+ ["bool_off"]=>
+ string(0) ""
+ ["bool_no"]=>
+ string(0) ""
+ ["bool_none"]=>
+ string(0) ""
+ ["bool_null"]=>
+ string(0) ""
+ }
+ ["strings"]=>
+ array(8) {
+ ["string_true"]=>
+ string(4) "true"
+ ["string_yes"]=>
+ string(4) " yes"
+ ["string_on"]=>
+ string(5) " on "
+ ["string_false"]=>
+ string(5) "false"
+ ["string_off"]=>
+ string(4) "Off "
+ ["string_no"]=>
+ string(4) "No "
+ ["string_none"]=>
+ string(5) " NoNe"
+ ["string_null"]=>
+ string(4) "NULl"
+ }
+}
+Done.
diff --git a/ext/standard/tests/general_functions/parse_ini_file.phpt b/ext/standard/tests/general_functions/parse_ini_file.phpt
index 399a224db9..62ed5c79ce 100644
--- a/ext/standard/tests/general_functions/parse_ini_file.phpt
+++ b/ext/standard/tests/general_functions/parse_ini_file.phpt
@@ -1,12 +1,13 @@
--TEST--
-parse_ini_file() tests
+parse_ini_file() multiple calls
--FILE--
<?php
$filename = dirname(__FILE__)."/parse_ini_file.dat";
+@unlink($filename); /* Make sure the file really does not exist! */
var_dump(parse_ini_file());
-var_dump(parse_ini_file(1,1,1));
+var_dump(parse_ini_file(1,1,1,1));
var_dump(parse_ini_file($filename));
var_dump(parse_ini_file($filename, true));
@@ -15,7 +16,6 @@ test =
";
file_put_contents($filename, $ini);
var_dump(parse_ini_file($filename));
-
$ini = "
test==
";
@@ -81,7 +81,6 @@ $ini = "
";
file_put_contents($filename, $ini);
var_dump(parse_ini_file($filename, true));
-
$ini = "
test=test2
test=test3
@@ -90,22 +89,21 @@ test=test4
file_put_contents($filename, $ini);
var_dump(parse_ini_file($filename, true));
-
@unlink($filename);
echo "Done\n";
?>
--EXPECTF--
-Warning: Wrong parameter count for parse_ini_file() in %s on line %d
-NULL
+Warning: parse_ini_file() expects at least 1 parameter, 0 given in %sparse_ini_file.php on line 6
+bool(false)
-Warning: Wrong parameter count for parse_ini_file() in %s on line %d
-NULL
+Warning: parse_ini_file() expects at most 3 parameters, 4 given in %sparse_ini_file.php on line 7
+bool(false)
-Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d
+Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %sparse_ini_file.php on line 8
array(0) {
}
-Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %s on line %d
+Warning: parse_ini_file(%sparse_ini_file.dat): failed to open stream: No such file or directory in %sparse_ini_file.php on line 9
array(0) {
}
array(1) {
@@ -113,15 +111,15 @@ array(1) {
string(0) ""
}
-Warning: Error parsing %sparse_ini_file.dat on line 2
- in %s on line %d
+Warning: syntax error, unexpected '=' in %sparse_ini_file.dat on line 2
+ in %sparse_ini_file.php on line 20
array(1) {
["test"]=>
string(0) ""
}
-Warning: Error parsing %sparse_ini_file.dat on line 2
- in %s on line %d
+Warning: syntax error, unexpected '=' in %sparse_ini_file.dat on line 2
+ in %sparse_ini_file.php on line 26
array(1) {
["test"]=>
string(4) "test"