The PHP Interpreter
Go to file
Christoph M. Becker 3b0f051193 Allow empty $escape to eschew escaping CSV
Albeit CSV is still a widespread data exchange format, it has never been
officially standardized.  There exists, however, the “informational” RFC
4180[1] which has no notion of escape characters, but rather defines
`escaped` as strings enclosed in double-quotes where contained
double-quotes have to be doubled.  While this concept is supported by
PHP's implementation (`$enclosure`), the `$escape` sometimes interferes,
so that `fgetcsv()` is unable to correctly parse externally generated
CSV, and `fputcsv()` is sometimes generating non-compliant CSV.  Since
PHP's `$escape` concept is availble for many years, we cannot drop it
for BC reasons (even though many consider it as bug).  Instead we allow
to pass an empty string as `$escape` parameter to the respective
functions, which results in ignoring/omitting any escaping, and as such
is more inline with RFC 4180.  It is noteworthy that this is almost no
userland BC break, since formerly most functions did not accept an empty
string, and failed in this case.  The only exception was `str_getcsv()`
which did accept an empty string, and used a backslash as escape
character then (which appears to be unintended behavior, anyway).

The changed functions are `fputcsv()`, `fgetcsv()` and `str_getcsv()`,
and also the `::setCsvControl()`, `::getCsvControl()`, `::fputcsv()`,
and `::fgetcsv()` methods of `SplFileObject`.

The implementation also changes the type of the escape parameter of the
PHP_APIs `php_fgetcsv()` and `php_fputcsv()` from `char` to `int`, where
`PHP_CSV_NO_ESCAPE` means to ignore/omit escaping.  The parameter
accepts the same values as `isalpha()` and friends, i.e. “the value of
which shall be representable as an `unsigned char` or shall equal the
value of the macro `EOF`.  If the argument has any other value, the
behavior is undefined.”  This is a subtle BC break, since the character
`chr(128)` has the value `-1` if `char` is signed, and so likely would
be confused with `EOF` when converted to `int`.  We consider this BC
break to be acceptable, since it's rather unlikely that anybody uses
`chr(128)` as escape character, and it easily can be fixed by casting
all `escape` arguments to `unsigned char`.

This patch implements the feature requests 38301[2] and 51496[3].

[1] <https://tools.ietf.org/html/rfc4180>
[2] <https://bugs.php.net/bug.php?id=38301>
[3] <https://bugs.php.net/bug.php?id=51496>
2018-12-15 14:38:15 +01:00
appveyor Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
build Set AC_CONFIG_AUX_DIR to build directory 2018-12-10 08:11:44 +01:00
ext Allow empty $escape to eschew escaping CSV 2018-12-15 14:38:15 +01:00
main Fix version numbers in main branch 2018-12-10 00:16:23 +01:00
pear Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
sapi Implement FR #72510: systemd service should be hardened 2018-12-12 17:12:02 +01:00
scripts Set AC_CONFIG_AUX_DIR to build directory 2018-12-10 08:11:44 +01:00
tests Remove some mentions of RECOVERABLE_ERROR in tests 2018-11-15 22:13:46 +01:00
travis ext/curl: port to pkg-config macro and consistently require its use 2018-12-09 17:28:02 +01:00
TSRM Future-proof email addresses... 2018-11-01 18:30:28 +02:00
win32 Future-proof email addresses... 2018-11-01 18:30:28 +02:00
Zend Provide is_zend_ptr() function to check if a pointer lays in Zend MM heap. 2018-12-12 13:02:28 +03:00
.appveyor.yml Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
.editorconfig Update .editorconfig with some more configs 2017-10-19 11:53:37 +01:00
.gdbinit Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
.gitattributes Fix .gitattributes 2018-10-20 22:58:27 +02:00
.gitignore Remove lexer files generated by RE2C 2018-11-11 02:55:46 +01:00
.travis.yml Merge branch 'PHP-7.2' into PHP-7.3 2018-12-03 00:42:55 -08:00
acinclude.m4 ext/intl: Use pkg-config to detect icu 2018-12-09 16:59:24 +01:00
buildconf Merge branch 'PHP-7.2' into PHP-7.3 2018-10-20 09:54:00 +02:00
buildconf.bat Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
CODING_STANDARDS Move all testing docs to qa.php.net 2018-10-18 08:01:22 +02:00
configure.ac Set AC_CONFIG_AUX_DIR to build directory 2018-12-10 08:11:44 +01:00
CONTRIBUTING.md Set AC_CONFIG_AUX_DIR to build directory 2018-12-10 08:11:44 +01:00
CREDITS Update http to https 2018-06-25 08:31:32 +02:00
EXTENSIONS [ci skip] Add myself as sqlite3 maintainer, officially 2018-11-29 13:49:55 +01:00
footer Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
genfiles Remove lexer files generated by RE2C 2018-11-11 02:55:46 +01:00
header Remove unused Git attributes ident 2018-07-25 00:53:25 +02:00
INSTALL Update http to https 2018-06-25 08:31:32 +02:00
LICENSE Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
makedist Set AC_CONFIG_AUX_DIR to build directory 2018-12-10 08:11:44 +01:00
Makefile.gcov Add forked and maintained extension in php-src from GCOV 2018-12-02 22:36:52 -02:00
Makefile.global Remove stamp-h 2018-10-18 08:35:43 +02:00
NEWS Allow empty $escape to eschew escaping CSV 2018-12-15 14:38:15 +01:00
php7.spec.in Replaces php5 with php7, without whitespace changes. 2014-09-20 10:01:44 +02:00
php.gif
php.ini-development Merge branch 'PHP-7.3' 2018-12-08 10:25:35 +01:00
php.ini-production Merge branch 'PHP-7.3' 2018-12-08 10:25:35 +01:00
README.EXT_SKEL Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
README.GIT-RULES [ci skip] PHP 7.1 is now security-only branch 2018-11-23 21:20:13 +01:00
README.input_filter Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
README.MAILINGLIST_RULES - mention rfc 1855 2008-01-17 14:37:58 +00:00
README.md Move all testing docs to qa.php.net 2018-10-18 08:01:22 +02:00
README.NEW-OUTPUT-API Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
README.PARAMETER_PARSING_API Link to the fast_zpp RFC 2018-12-10 12:53:12 +11:00
README.REDIST.BINS Unbundle libsqlite3 2018-10-06 12:36:55 +02:00
README.RELEASE_PROCESS ZEND_VERSION should be in sync with PHP_VERSION and friends 2018-12-07 15:11:48 +01:00
README.SELF-CONTAINED-EXTENSIONS [ci skip] Remove automake and aclocal in comments 2018-10-21 13:06:58 +02:00
README.STREAMS Trim trailing whitespace in source code files 2018-10-13 14:17:28 +02:00
README.SUBMITTING_PATCH Move all testing docs to qa.php.net 2018-10-18 08:01:22 +02:00
README.UNIX-BUILD-SYSTEM [ci skip] Remove automake and aclocal in comments 2018-10-21 13:06:58 +02:00
README.WIN32-BUILD-SYSTEM Sync leading and final newlines in source code files 2018-10-14 12:56:38 +02:00
run-tests.php Merge remote-tracking branch 'github/pr/3345' 2018-12-02 16:00:44 -08:00
snapshot
UPGRADING Allow empty $escape to eschew escaping CSV 2018-12-15 14:38:15 +01:00
UPGRADING.INTERNALS Allow empty $escape to eschew escaping CSV 2018-12-15 14:38:15 +01:00
vcsclean Support "git worktree" 2016-08-11 08:08:26 +09:00

The PHP Interpreter

This is the github mirror of the official PHP repository located at https://git.php.net.

Build Status Build status

Pull Requests

PHP accepts pull requests via github. Discussions are done on github, but depending on the topic can also be relayed to the official PHP developer mailing list internals@lists.php.net.

New features require an RFC and must be accepted by the developers. See https://wiki.php.net/rfc and https://wiki.php.net/rfc/voting for more information on the process.

Bug fixes do not require an RFC, but require a bugtracker ticket. Always open a ticket at https://bugs.php.net and reference the bug id using #NNNNNN.

Fix #55371: get_magic_quotes_gpc() throws deprecation warning

After removing magic quotes, the get_magic_quotes_gpc function caused
a deprecate warning. get_magic_quotes_gpc can be used to detected
the magic_quotes behavior and therefore should not raise a warning at any
time. The patch removes this warning

We do not merge pull requests directly on github. All PRs will be pulled and pushed through https://git.php.net.

Guidelines for contributors

Testing

To run tests the make test is used after successful compilation of the sources.

See Creating new test files chapter for more information about testing.