The title pretty much says it all.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | jsreject-string-fix-to-br-1612960.patch | 608 bytes | philosurfer |
| #2 | jsreject-stringfix-1612960.patch | 576 bytes | philosurfer |
The title pretty much says it all.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | jsreject-string-fix-to-br-1612960.patch | 608 bytes | philosurfer |
| #2 | jsreject-stringfix-1612960.patch | 576 bytes | philosurfer |
Comments
Comment #1
philosurfer commentedgetting the same problem. The string is not converting carriage returns to html for the JS.
Comment #2
philosurfer commentedhere is a patch that strips hard returns from the paragraph strings
Comment #3
philosurfer commentedComment #4
reg commentedInstead of stripping NL's can't you use
nl2br()so people can still format extra lines if they want? That would be nicer to the user.Comment #5
philosurfer commentedgood call i was half asleep when i did this...
fyi.. the nl2br() doesnt see the hard returns properly, so using a str_replace() was still mandatory to get needed effect :D
I think there is better way to do this, scrubbing strings before passing them to JS... as soon as i find it, Ill post a third patch.
in the meantime.. here is this :)
Comment #6
philosurfer commentedComment #7
reg commentedJust looking at the code I see one problem in that different OS's are going to produce a different number of new lines (BR's). You might want to use Regex to convert all \r\n to to \n and \r to \n and then do a conversion to the HTML BR tag from \n or something with similar logic. With the code you have you will get 2 new lines on some OS's and one new line on others since between Linux, Mac & Window you get all three combinations.
However, as far as I know that is exactly what nl2br (http://us.php.net/manual/en/function.nl2br.php) does so I don't know what you mean by it doesn't see the hard returns properly. It's a pretty standard function that's been around forever.
Comment #8
entendu commented@Reg,
nl2br()sees the returns properly, but it doesn't replace them -- it only adds a<br />. So this:foo\nbarturns into this:
foo<br />\nbarwhich still breaks the js.
I committed @philosurfer's patch with one modification, I added "\r\n" to the needle array. That should get us going!
Comment #9
reg commentedGood solution.