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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 19:01:26 2024 UTC