From:
Operating system:
PHP version: Irrelevant
Package: PCRE related
Bug Type: Feature/Change Request
Bug description:enhance / change newline behavior
Description:
------------
At the moment (PHP bundled) PCRE is build with the default "#define NEWLINE
10".
As a result "$" means "\n" but not e.g. "\r\n" and "\r" remains as part of
the match. This is unexpected for some people, especially on Windows. See
the example below.
There are 3 solutions:
1)
Building PCRE with "#define NEWLINE -2", or with "#define NEWLINE -1"
(because PCRE is still build with Unicode support)
2)
Adding a INI option like "pcre.newline=any"
3)
Making PCRE_NEWLINE_ANY, PCRE_NEWLINE_CR, PCRE_NEWLINE_CRLF,
PCRE_NEWLINE_LF available to the userland (maybe as pattern modifier), like
you can do this with C using the PCRE library.
(Well, 1) is not essential if 2) and 3) is available)
Test script:
---------------
<?php
$str = "line1\r\nline2\r\nline3\r\n";
preg_match_all('/.+/', $str, $res);
var_dump($res);
?>
Expected result:
----------------
array(1) {
[0]=>
array(3) {
[0]=>
string(5) "line1"
[1]=>
string(5) "line2"
[2]=>
string(5) "line3"
}
}
Actual result:
--------------
array(1) {
[0]=>
array(3) {
[0]=>
" string(6) "line1
[1]=>
" string(6) "line2
[2]=>
" string(6) "line3
}
}
--
Edit bug report at http://bugs.php.net/bug.php?id=54223&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54223&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54223&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54223&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54223&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54223&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54223&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54223&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54223&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54223&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54223&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54223&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54223&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54223&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54223&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54223&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54223&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54223&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54223&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54223&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54223&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54223&r=mysqlcfg