php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66426 nl2br option to replace html5 newlines
Submitted: 2014-01-06 15:29 UTC Modified: 2014-01-07 07:58 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: hajo at csphere dot eu Assigned:
Status: Open Package: Strings related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hajo at csphere dot eu
New email:
PHP Version: OS:

 

 [2014-01-06 15:29 UTC] hajo at csphere dot eu
Description:
------------
copied from the documentation nl2br can replace the following:

\r\n, \n\r, \n und \r

it might be an improvement if it can also replace the html5 entity &newline;

e.g. when htmlentities is used with ENT_HTML5 and nl2br afterwards all newlines are no longer replaced due to the ENT_HTML5 flag, but with all other flags this works. with htmlspecialchars this even works with the ENT_HTML5 flag as its not replacing that much entities.

an alternative would be to provide an option to skip or change the &Newline; entity more easily. this ticket is just opened to suggest a way to ease the use of nl2br regarding html5.

Test script:
---------------
$test = "abc\n"defg";

$escape = htmlentities($test, ENT_HTML5);

$result = nl2br($escape);

Expected result:
----------------
var_dump($result); // string "abc&Newline;<br />defg"

Actual result:
--------------
var_dump($result); // string "abc&Newline;defg"

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Dec 08 21:01:25 2019 UTC