php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50608 last "<" character drops rest of the field with explode and preg_splits the
Submitted: 2009-12-29 23:34 UTC Modified: 2009-12-30 19:48 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: dlazesz at walla dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.12 OS: Ubuntu 9.10, Debian 4.0
Private report: No CVE-ID: None
 [2009-12-29 23:34 UTC] dlazesz at walla dot com
Description:
------------
last "<" character drops the rest of the field with explode and preg_split

Reproduce code:
---------------
print_r(explode(",",'"Foo Bar" <foobar@example.com>, Second address...'));
print_r(preg_split("/,/",'"Foo Bar" <foobar@example.com>, Second address...'));
print_r(explode(",",'"Foo Bar" foobar@example.com>, Works.'));
print_r(preg_split("/,/",'"Foo Bar" foobar@example.com>, Works.'));
print_r(explode(",",'"Foo Bar" <<foobar@example.com>, Something missing.'));
print_r(preg_split("/,/",'"Foo Bar" <<foobar@example.com>, Something missing.'));

Expected result:
----------------
Array ( [0] => "Foo Bar" <foobar@example.com>  [1] => Second address... )
Array ( [0] => "Foo Bar" <foobar@example.com>  [1] => Second address... )
Array ( [0] => "Foo Bar" foobar@example.com>  [1] => Works. )
Array ( [0] => "Foo Bar" foobar@example.com>  [1] => Works. )
Array ( [0] => "Foo Bar" <foobar@example.com>  [1] => Something missing. )
Array ( [0] => "Foo Bar" <foobar@example.com>  [1] => Something missing. )

Actual result:
--------------
Array ( [0] => "Foo Bar"  [1] => Second address... )
Array ( [0] => "Foo Bar"  [1] => Second address... )
Array ( [0] => "Foo Bar" foobar@example.com>  [1] => Works. )
Array ( [0] => "Foo Bar" foobar@example.com>  [1] => Works. )
Array ( [0] => "Foo Bar" <  [1] => Something missing. )
Array ( [0] => "Foo Bar" <  [1] => Something missing. )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-30 00:30 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Use your browser's View source function or the command line for a test - the <> is treated like HTML by your browser ...
 [2009-12-30 19:48 UTC] dlazesz at walla dot com
Thanks. I'd never thought of that.

There should be a big sign at http://bugs.php.net/how-to-report.php

"Also test in the command line!"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 11:01:28 2024 UTC