-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nl2br ignores \r in 3.3.0 #3815
Comments
It fails for me even in 3.2.0. |
Yeah, we screw up on |
Yeah, that would not be a big deal. But the major problem is that it leads to a data loss; look at the output in 3.3.0, "my" is completely missing and one tag is partially lost as well. I guess that, under some circumstances, it might be even considered as a security problem. |
I believe your data loss is actually just the carriage return moving the printing cursor to the start of the line and then you write over your other characters. |
@MaideCa: Right, that would be the case. :) It got split from \n and became interpreted in output in a confusing way... |
Summary: nl2br() now matches PHP to support prepending of html new lines on carriage returns in addition to newlines. We also handle special cases when there is a carriage return beside a newline; each pair only get one html new line instead of two. Fixes facebook#3815 Closes facebook#3821 Reviewed By: @ptarjan Differential Revision: D1571327
On PHP, the output is correct:
On HHVM, output is broken and even tags are broken:
And even worse if 2nd parameter is FALSE (no XHTML) - still generates XHTML, but broken even more:
On 3.2.0 and earlier, output was wrong as well, but never broken:
The text was updated successfully, but these errors were encountered: